JS: code help | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

JS: code help

I’m in the process of making an image slider. With next and previous buttons. I had the next button working just fine. And then I added the “previous” button. Still worked fine. The problem is when you click next and get to 9:8 (console) I tried to change numbers around and tried to figure out, but not sure what’s happening. https://code.sololearn.com/WVFKv0ICtAd8/?ref=app

26th Apr 2020, 7:01 AM
Ginfio
Ginfio - avatar
2 Answers
+ 1
Replace lines 21 and 22 with "else".
26th Apr 2020, 7:14 AM
Manu_1-9-8-5
Manu_1-9-8-5 - avatar
+ 1
if(i > 9){ i = 0; x = 9; } else if(i == 1){ x = 0} else if (i <= 9){ x = i - 1; }
26th Apr 2020, 7:17 AM
visph
visph - avatar