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

Darrin Spell Jr
Darrin Spell Jr
Full Stack JavaScript Techdegree Student 10,303 Points

I don't understand what I am doing wrong with this for loop.

When I test my code out and preview it. It prints out the numbers 4 to 156 to the console. Am I missing something or does it want it done a specific way that I haven't thought about yet?

script.js
var numbers = '';


for ( var count = 1; count <= 156; count += 1 ) {
  numbers += ' ' + count
}
console.log(numbers)

2 Answers

Hey, I see why you did it that way, makes sense. The error message kind hints that console.log needs to be called for every number. Also you start with 1 when they want 4. Otherwise its good.

for ( var count = 4; count <= 156; count += 1 ) {
  console.log(count);
}