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 trialMichael Paccione
9,017 PointsChallenge Bug - Log even #2-24
I think there is a bug. This code does what is asked.
for (var i = 2; i <= 24; i++){
if ( i % 2 == 0 ) {
console.log('' + i + '')
}
}
1 Answer
William Li
Courses Plus Student 26,868 PointsNo, it's not a bug, you should do console.log(i)
instead.
Also, your solution is good, and you can simplify the code a little bit more
for(var i=2; i<=24; i+=2) {
console.log(i);
}
Michael Paccione
9,017 PointsMichael Paccione
9,017 PointsFacepalm
Thank You!