Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript JavaScript Loops, Arrays and Objects Simplify Repetitive Tasks with Loops Create a for Loop

Duncan Murtagh
Duncan Murtagh
1,557 Points

"Create a for loop that logs the numbers 4 to 156 to the console" Challenge - solution not being accepted

Hi, please help my solution to the Challenge "Create a for loop that logs the numbers 4 to 156 to the console. To log a value to the console use the console.log( ) method." works in the Console (it delivers what is asked, in my view) but I am getting this message "Bummer: You need to log out EVERY number from 4 to 156 to the console. Your loop calls the console.log() method 154 times."

script.js
let number = '';
for ( let number=4; number <=156; number+=1 ) {
  console.log(number);
}
console.log("all finished");

2 Answers

Steven Parker
Steven Parker
217,573 Points

Log only the numbers, the instructions didn't ask for a "finished" message.

Also, you don't need to create "number" before the loop. The one created inside the loop will "shadow" it anyway.

Duncan Murtagh
Duncan Murtagh
1,557 Points

Thanks Steven, once again.

I removed the console.log("all finished"); and it worked. I really think Treehouse shouldn't judge it as a 'fail' if you leave a simple console.log line in.

Steven Parker
Steven Parker
217,573 Points

I'd guess the checking mechanism just counts how many outputs are made without looking at their contents.