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 trialXiaolei Wheelock
3,027 Pointsmy answer runs correctly but the code challenge won't pass it.
I am at JavaScript Loops section. the very last code challenge asked me to replace the repeated console.log with a simple loop code. i did that. var string =' '; for(var i=2; i<=24; i+=2) { string +=i +' '; } console.log(string);
but it kept on saying " Bummer! you logged 1 number but you need to log 12 numbers" I tried in chrome console, it did log 12 numbers. I can't find a way to get pass this code challenge. Please help.
var string =' ';
for(var i=2; i<=24; i+=2)
{
string +=i +' ';
}
console.log(string);
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JavaScript Loops</title>
</head>
<body>
<script src="script.js"></script>
</body>
</html>
2 Answers
Caleb Kleveter
Treehouse Moderator 37,862 PointsCheck out this forum post, I hope it helps!
Jonathan Grieve
Treehouse Moderator 91,253 PointsTry adding string[i] + ' ':
In your code blog
This should work. If you're still getting the 12 numbers it might be the correct code but the challenge is looking got a specific answer
Hope this helps you :)