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 trialAndrea Gylling
2,796 PointsWorks in workspaces but not being accepted in code challenge. Why not?
When I preview this code in workspaces, it logs 4-156 to the console, as the challenge requires.
However, I'm getting a "Bummer"-message when I check the work in the challenge, saying "You need to log out EVERY number from 4 to 156 to the console. Your loop calls the console.log() method 1 times." I don't understand what's going wrong.
var html = ' ';
for (var i = 4; i <= 156; i += 1){ html += i + ' '; }
console.log(html);
var html = ' ';
for (var i = 4; i <= 156; i += 1){
html += i + ' ';
}
console.log(html);
1 Answer
Steven Parker
231,248 PointsIt looks like you already discovered that the challenge wanted you to log each number individually.
This is a also a good opportunity to remind other students to be careful about testing challenges in external IDEs and REPLs. It's easy to misinterpret the objective and become frustrated when the code seems to produce a "right" answer.
It's also easy to make assumptions about the test data and to actually get correct results with code that will perform differently when the validator tests it more rigorously with its own data.
Happy coding, everyone!
Andrea Gylling
2,796 PointsAndrea Gylling
2,796 PointsProblem solved.