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

For loops, i am not sure how to answer this code challenge on For loops.

creating a For Loop for the number 4 to 156

var number = ' ';
for (var i = 1; i <= 152; i += 1) {

2 Answers

Tabatha Trahan
Tabatha Trahan
18,392 Points

Hi Priscilla. Your for loop is so close to being the correct answer for the challenge. Take a look at your initializer and your condition again as you read what the challenge is asking. It wants you to start at 4 and go up to (including) 156. If you set i to equal 4, and continue looping until i is greater than or equal to 156,(so while i is less than or equal to 156 you keep looping) you should be good to go.

Thank you Tabatha...

Adam N
Adam N
62,174 Points

In addition to what Tabatha Trahan said, in the body of the loop you also need to be logging the current value the loop is on. Logging the number variable will just print an empty string for however many times your loop is set to run.

Thanks Adam..