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 trialKaren Shumate
13,579 PointsCreate a for loop that logs the numbers 4 to 156 to the console method.
How do I get it to repeat more than one time. what am I doing wrong.
var counter= 0;
var times = 156
var html = ' ';
console.log( i );
for ( var i = 4; i <=156; i += 1 ) {
html += '<div>' + i + '</div>';
}
document.write( counter + "times" )
counter += 1;
1 Answer
Steven Parker
231,275 PointsYour loop builds up a big string in "html", but then that variable isn't used for anything in the later code. But even if it were, that's not what the challenge is asking for. Here's some hints that may help get you back on track:
- you won't need to use any HTML tags in this challenge
- you also will not need to write anything to the document, the output should go to the console instead
- the instructions say, "To log a value to the console use the
console.log( )
method." - you can log each number easily by putting the logging statement inside the loop