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 trialBen Mohammad
5,659 PointsI'M SURE THERE AINT A TYPO HERE.
Please elaborate on where it's wrong.......
for (var num = 4; num <= 156; num+= 1){
}
console.log(num);
2 Answers
Benjamin Barslev Nielsen
18,958 PointsI assume that the expected result was that you should log the numbers 4, 5, 6, ..., 156 in the console. However your code only logs 157, and this is because you do not have console.log(num) inside your for-loop.
The code should have been:
for (var num = 4; num <= 156; num+= 1){
console.log(num);
}
Steve Hunter
57,712 PointsHi Ben,
If you put your console.log()
call inside the curly braces of the for
loop, this will work just fine.
Steve.
Ben Mohammad
5,659 PointsBen Mohammad
5,659 PointsThanks