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 trialNipi Tiri
2,988 Pointsfor (var i = 4; i <= 156; i++) { console.log([i]); } I dont know
for (var i = 4; i <= 156; i++)
{
console.log([i]);
}
Its all true, why it dont let me pass?
2 Answers
Jonathan Ankiewicz
17,901 Pointsfor (var i = 4; i <=156; i++)
{
console.log(i);
}
Your for loop is not true. The square brackets aren't used for calling out the single variable.
sizwengubane
15,244 PointsListen nipi u have messed the for loop's theory up The correct code is this
for (var i = 4; i <= 156; i++)
{
console.log(i);
}
U dont put 'i' inside of square brackets when u are just logging the number out to the console or when u are printing stuff directly to the document using document.write
U ONLY put [i] when u are dealing with arrays Lets say u have an array called 'colors'..inside that array u have 5 array items. If you want to loop through these array items u can do it with a for loop like this.....
for(var i = 0; i < colors.length; i++){
console.log(colors[i]);
}
Remember...u only use the counter with square brackets like this '[i]' only when looping through arrays Mark my answer as the best if i managed to help u
Chyno Deluxe
16,936 PointsChyno Deluxe
16,936 Points//Changed Comment to Answer