Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialDaniel Williams
Courses Plus Student 1,325 PointsCan't get the console log to show the numbers from 4 and 156.
Bummer! You need to log out EVERY number from 4 to 156 to the console. Your loop calls the console.log() method 1 times. This has been the response to the varied combinations I have tried
var number= '';
for (var i =4; i <=156; i += 1) {
i += 'number' + i + 'number';
}
console.log(number + i);
1 Answer
Emre Karakuz
9,162 PointsFirst of all, you don't need a varible name = ' ' to do this challenge
2-)You are already increasing the i value in the loop decleration with this code : ( i=4 ; i<=156; i += 1). So you dont need to increase it in the function block (between {})
3-) console.log is called after the for loop which means it will log the last i variable (156) to the console. To fix this, write console.log(i) inside the for loop.
for (var i =4; i <=156; i += 1) {
console.log(i);
}