JavaScript JavaScript Loops, Arrays and Objects Simplify Repetitive Tasks with Loops Create a for Loop

What's wrong with my code?

I'm getting a parse error and I don't know why.

script.js
for (var counter = 4; counter <= 156; counter += 1;) {
  console.log(i);
}
Emanuel Cabanga
Emanuel Cabanga
5,775 Points

i think it´s wrong because you put a semicolon before closing the parentheses.

1 Answer

KRIS NIKOLAISEN
KRIS NIKOLAISEN
54,164 Points

You have two issues:

1) There shouldn't be a semicolon after counter += 1. This is your parse error.

2) You created variable counter but then log variable i

Thanks! But why no semicolon there?