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 trialDavide Lamorte
7,000 PointsIs this a bug?
The challenge is:
"Create a for loop that logs the numbers 4 to 156 to the console. To log a value to the console use the console.log( ) method."
This is the error: "Bummer! You need to log out EVERY number from 4 to 156 to the console. Your loop calls the console.log() method 1 times."
I tried the code using the workspace and it works perfectly. I don't understand why it gives me the error.
Any ideas?
var n = " ";
for (var i = 4; i <= 156; i += 1 ) {
n += " " + i + " ";
}
console.log(n);
2 Answers
stjarnan
Front End Web Development Techdegree Graduate 56,488 PointsHi Davide,
It is not a bug, and while you could do like you did, they want you to do something else. They want you to log the number as part of the loop. Try logging your value inside of the loop.
Hint: There won't be a need for your n variable.
I hope that helps!
Jonas
stjarnan
Front End Web Development Techdegree Graduate 56,488 PointsHappy to help!
It can be tough sometimes when there is 50 ways to do something and the challenge-compiler wants a special one of them :)
Davide Lamorte
7,000 PointsDavide Lamorte
7,000 PointsThank you, I completed the challenge! The error sentece was misleading.