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 trialSezare Miguel
9,229 Pointsfor loop
What am I doing wrong here?
var number = 156;
for ( var i= 4; i <= 156; i += 4 ) {
number += '';
}
console.log(number)
1 Answer
John Clune
Courses Plus Student 4,951 Pointsfor (var number = 4; number <= 156; number++){
console.log(number);
}
You need to log numbers 4 - 156 to the console. As in 4, 5, 6, 7, 8 .... 156. So you start by saying for, then inside the brackets you declare and initialize a variable with a value of 4 (in this case I called it number so it's easier to understand). The second part checks if the number is less than or equal to 156 (as long as that is true the loop will keep running), and the third part increases the number by 1 every time the loop runs. The last thing is to put the log to the console inside the loop so that it prints out the value of number every time the loop runs. Hope that makes sense.
Sezare Miguel
9,229 PointsSezare Miguel
9,229 PointsShuu! you are brilliant, i will realy need your help with Js, i cant make it alone.