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

Tine Jakomini
Tine Jakomini
2,494 Points

Please help !

.

script.js
for ( var counter = 0; counter < 156; counter += 4)  {

} if (counter < 156)  {
      console.log(counter);
}

1 Answer

KRIS NIKOLAISEN
PRO
KRIS NIKOLAISEN
Pro Student 49,975 Points

The first error message you receive is Bummer: The console.log() method never ran. This is due to the closing bracket right before your if statement. That bracket should go to the very end of your code.

The if statement is unnecessary since you already have a condition included in your loop so you can remove that.

The instructions state log the numbers 4 to 156. So initialize counter at 4. Loop to 156 inclusive which means counter <= 156. And you are to log all numbers so they increment by one. The updated code is as follows:

for ( var counter = 4; counter <= 156; counter ++)  {
      console.log(counter);
}
Dario Bahena
Dario Bahena
10,688 Points
counter++ // good
counter ++ // not ideal