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 trialHelen King
9,717 PointsCreate a for loop that logs the numbers 4 to 156 to the console. To log a value to the console use the console.log( ) me
I'm struggling with these loops, I have a general idea of what needs to be written but don't know how to write it!
this is what I have so far....
var number = '';
for (var i = 4; i< 157; i += 1) {
}
console.log(i);
1 Answer
Jennifer Nordell
Treehouse TeacherOh if you only knew how close you are! First off you don't need the number variable as your "i" variable is all that's needed here. Then if you just place the console.log in your code block... voilรก! Here... see what I mean:
for (var i = 4; i< 157; i += 1) {
console.log(i);
}
Helen King
9,717 PointsHelen King
9,717 Pointsah i have my console log in the wrong place! thank you Jennifer :)