+ 1

[SOLVED] Display Today/Next Week algorithm. Can't get it right. HELP!

So I'm making a weekly scheduler and I'm having trouble with these two functions. If I press next_week, it works fine. But if I press next_week > today > next_week, the values for next week doesn't change back to its default. How can I fix this? https://code.sololearn.com/Wf9E30kRyDpo/?ref=app

12th Nov 2019, 5:04 AM
Isidro Brylle Mutia
Isidro Brylle Mutia - avatar
2 Respuestas
+ 4
1. Part one : Your bug 1.1 Problem : You did not re-initialize the variables. 1.2 Solution : Declare a function init() in which you initialize the variables. Call it every time you run nextweek() https://code.sololearn.com/WqZ7tgxAM8hC/?ref=app 2. Part two : The JavaScript way Use the Date method now() and Date() constructor. https://code.sololearn.com/WjOi1iPc9qfg/?ref=app P. S. I enjoyed Fairytail too.
12th Nov 2019, 9:33 AM
Gordon
Gordon - avatar
0
Gordon, huge thanks man. I only studied JavaScript for a week now. You've been a big help for my project. Thanks again mate! Godbless! EDIT: BTW, I fixed it and added a little handy feature to save me some trouble. https://code.sololearn.com/WB5q8uzRTg4r/?ref=app
15th Nov 2019, 11:47 PM
Isidro Brylle Mutia
Isidro Brylle Mutia - avatar