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.

danon62
4,354 PointsCreate a for loop
Hello. Is my code wrong?
Bummer: The console should display 5
the first time through the loop and 100
the last time.
let counter;
for (counter = 5; counter <= 100; counter++ ) {
console.log(`The number is ${counter}`);
}
3 Answers

MD MONIRUZZAMAN
6,014 Pointsfor (let counter = 5; counter <= 100; counter++ ) {
console.log(`The number is ${counter}`);
}
You should avoid this line
console.log(`The number is ${counter}`);
& simply type
console.log(counter);
Your code is more than perfect but your answer need to be according to the question otherwise in most cases,system will not let you pass.BTW,you can initialize variable(count) inside the loop, if you wish to invoke the variable inside the loop.It looks clean & also good coding practice.
Hopefully it will helps. Happy coding.😃

Rabin Gharti Magar
Front End Web Development Techdegree Graduate 20,137 PointsHey danon62,
You only have to log a number so you can remove template literals
from console method
.
Here's the final code:
let counter;
for (counter = 5; counter <= 100; counter++ ) {
console.log(counter);
}
Hope this helps!

Clare Yeadon
5,539 PointsThank you! I was stuck here too but your answer helped.

danon62
4,354 PointsThe second solution has helped a lot, thanks very much!!!