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 trial![](https://ecs-static.teamtreehouse.com/assets/views/marketing/shared/community-banner-white-47072046c51352fe6a69f5e691ff5700b28bb11d45197d7bdf066d9ea3f72d0c.webp)
![Christopher Anderson](https://secure.gravatar.com/avatar/7d1266749830b26cdf0c74f5903ca092?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Christopher Anderson
1,763 Pointswhat is the syntax error
I am suppose to write a for loop therefore I can eliminate the 24 console.log statements but this code is not passing what is the problem.
for (let i = 0; i < 24; i+=2) {
console.log(i);
}
/*console.log(2);
console.log(4);
console.log(6);
console.log(8);
console.log(10);
console.log(12);
console.log(14);
console.log(16);
console.log(18);
console.log(20);
console.log(22);
console.log(24);*/
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JavaScript Loops</title>
</head>
<body>
<script src="script.js"></script>
</body>
</html>
3 Answers
![David McNeill](https://uploads.teamtreehouse.com/production/profile-photos/103885/micro_david_bw.jpg)
David McNeill
44,438 PointsHey Christopher,
It looks like the code challenge may not accept the use of 'let' as a keyword, it expects 'var' instead. It might be an older JS course before ES2015 terms like 'let' or 'const' would have been acceptable as answers. So you haven't done anything wrong! The course might just need updating, certainly the more recent JS courses use ES2015 syntax a lot more.
Just FYI, you should also initialise your counter variable at 2, not 0. The challenge is expecting the first log value to be 2.
Good luck!
![Brendan Whiting](https://uploads.teamtreehouse.com/production/profile-photos/2109002/micro_picture.jpg)
Brendan Whiting
Front End Web Development Techdegree Graduate 84,738 PointsIt seems the challenge is using an older version of javascript. Try using var
instead of let
.
![Steven Parker](https://uploads.teamtreehouse.com/production/profile-photos/969492/micro_tool_chess_set_2.jpg)
Steven Parker
231,128 PointsThere's no syntax error from the standpoint of ES2015, but this challenge validator apparently does not recognize the newer keywords. Try using "var" instead of "let".
You also need modify your range a bit. The challenge wants you to log "the even numbers from 2 to 24".
Regarding the "let/var" issue, you might want to submit a bug report about it to the Support folks.
Christopher Anderson
1,763 PointsChristopher Anderson
1,763 PointsThank you David.