What if you were asked to do this without a for loop? ;)
in that case, see some of the other clever comments to the post :)
While loop saves the day!
Or better yet ... use some functional programming!
.map((_, i) => i + 1)
.filter((num) => num % 2 !== 0)
We're a place where coders share, stay up-to-date and grow their careers.
We strive for transparency and don't collect excess data.