The following code is intended to output the day that comes before and after the dayName. However, I run into trouble when I have saturdays and sundays involved; I'm wondering why returnNext() is returning the same day instead of what comes after it, and why returnprevious() does the opposite. Do I need to include the dayNum in the parameters or something?
In the function returnNext(), dayNum++ is executed. Let's say the dayNum was seven, now 8. The block of code evaluating whether or not dayNum is 8 runs, if true setting dayNum to 1. Somehow, it still returns saturday, or dayNum = 7 basically. If I set the day to sunday, it returns the value sunday as well.
Is dayNum not the same throughout each code block? I thought, maybe if it's 7 when constructed, that be 7 each time a new code block is loaded.
Edit: Lesson learned, if you have to use the same variable in multiple code blocks but you want it to be the same, make a dummy copy of it to use.