7 Practice Counting Down


#1

I truly baffeld, I wrote this code here:

for (var i = 10; i >= 0; i--)
{
console.log(i);
};

I thought it would:

-define the variable as 10
- it would see the variable is greater or equal to 0
-it would subtract 1
-it would print the variable

Where have I gone wrong in my logic?


#2

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

I do not see any problems with your code, the only difference I see between my answer and yours is that your start statement "{" and is on a different line, that may be the issue but I am not sure, please try this and reply to me if it works or not.


#3

As @claradavies said it doesn't look that wrong. Did you try to refresh the page? And what is the error message you're getting?


#4

SyntaxError: Unexpected token for

That's it, I'll try refreshing and seeing what happens. Maybe I'll contact codecademy :stuck_out_tongue:


#5

Didn't work out. :confused:
contacting codecademy about it


#6

I know what is wrong. This is what you are doing:
for(var i = 10; i >= 0; i--) {
You are not supposed to have VAR inside the loop. It should look like this:
for(I = 10; i>=0; i--) {
(code block)
}


#7

The var is actually correct here also your second approach doesn't make much sense as you're using a I to start at 10 but using small i in the process.


#9

Hey @tagwhiz35336, I was having the same trouble you were. I don't think your code is wrong, I just don't think it's exactly what Codecademy wanted. After re-reading the hint, I tried setting the condition to "i > -1" and that worked for me. Hope that helps!


#10

It is correct just move the } up a line


#11

This worked fine for me. Try using Chrome and refreshing, that “fix” usually works for me.


#13