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 trialDustin McGrew
1,613 PointsMy console log looks like this: 12345678910111213141516......156. Why is that not a correct answer?
This is the code I came up with...
var numbers = '';
for(var i = 4; i < 157; i+=1){ numbers += i; }
console.log(numbers);
1 Answer
Jeff Lemay
14,268 Points- Your console.log should be inside the for loop
- You want to print 'i' in the console, not 'numbers'
- No need to set an empty 'numbers' variable at the top
for ( var i = 4; i <= 156; i += 1 ) { console.log(i); }
Jeff Lemay
14,268 PointsJeff Lemay
14,268 Pointsand 4. In the parameters for the for loop, you already tell the loop to add 1 to 'i' every time you go through the loop (i += 1). No need to set that inside the for loop.
Dustin McGrew
1,613 PointsDustin McGrew
1,613 PointsOk, I swear this is what I had originally but I got an error about calling the console.log function 156 times.