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 trialTakuya Hirata
23,296 Pointscreate a for loop
I am stuck. Please help me out. Thank you very much for your help.
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.
var number;
for ( var i = 4; i <= 156; i += 1 ) {
number += i
console.log(number);
}
3 Answers
Michael Fazekas
630 Pointsin your for loop for number += i take out the + sign and make it number = i; don't forget your semicolon.
Jacob Mishkin
23,118 PointsIt looks like there an issue with the variable in the challenge, try logging i to the console.
Dave StSomeWhere
19,870 PointsLooks like your loop is setup correctly, what's the purpose of the variable number? Don't you already have a variable with the value you desire?
Tianni Myers
10,453 PointsTianni Myers
10,453 PointsTry this: