7. Practice counting down


What's wrong?

for (var i = 10; i >= 0; i =- 1) {
I keep getting an error message that says that I didn't log a number.

Replace this line with your code.


The 1 at the end is not necessary.
The i(--) at the end is the solution itself because the "--" its like a shortcut for Minus one
so your code should look like that:

for (var i = 10; i >= 0; i --) {


 i =- 1

this sets i to be -1 so your loop runs once then the reassignment happens and then i is no longer greater than 0 and so the loop stops. What you probably had in mind was i-=1 which is a shortcut for i=i-1 or as @funct1on mentioned you could as well use i-- or --i if you only want to change i by 1 (the version of i-=x works for any number not just 1).


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.