+ 1
JavaScript Odd Number Output
Why does it output multiples of three instead of odd numbers? https://code.sololearn.com/WIAnwKTSfCJZ/?ref=app
5 Respuestas
+ 3
Your code is incrementing i twice. Take another look at it, especially the for loop.
+ 2
In line 1 you add 1 every time the loop starts and in line 2 you add 2 every time the loop runs.
So, 1 + 2 = 3 (that's why it shows multiples of 3).
You should only add once, instead of i++ (incrementing th value) you should add 2 to i.
Happy coding 🤠
+ 2
// To Improve Your Code
for(let i=1; i<20; i+=2) console.log(i);
+ 2
Happy to help 🤠