My problem:
I have an array called "weekdays":
const weekdays = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"];
Imagine it is Saturday and I want to know how many days it is until Tuesday (obviously 3 days). How can I loop through the array - starting at "Sat" and continue at the beginning until it reaches "Tue"?
My code so far:
const weekdays = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"]; const start = weekdays.indexOf("Sat"); const end = weekdays.indexOf("Tue"); let howManyDays = 0; for (let i = start; i < end; i = (i + 1) % weekdays.length) { howManyDays = howManyDays + 1; } However, it seems to be that "howManyDays" is still 0 when I run the code in the console in the browser.