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 trialTrevon Allen
7,902 Pointsanyone know where I'm going wrong?
its saying I'm logging 1 number and need to log 12 I know I'm missing something in this but not sure what any help is appreciated
var num = 0;
var number;
function number(){
return console.log();
}
do{
num += 2
}while (num < 24){
}
number();
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JavaScript Loops</title>
</head>
<body>
<script src="script.js"></script>
</body>
</html>
2 Answers
Steven Parker
231,275 PointsHere's a few hints:
- you don't need a function for this challenge
- but if you want to use one, it needs to take an argument (and log it out)
- you need to log the number (or call your function) from inside the loop
Christian Clarke
7,963 PointsLooking at this there are probably a few things you can change to get it to work! First, it looks like you you're calling a function once which will only give you a singular log. You can just log the number within the loop instead of doing that separately! Second, be sure that you have something in the log method i.e console.log(num).
Trevon Allen
7,902 Pointsappreciate the guidance I was able to use a for loop to resolve it for( I=2; I<25; I+=2){ console.log(i); }
putting the I in the console definitely helped appreciate it
Trevon Allen
7,902 PointsTrevon Allen
7,902 Pointsappreciate the guidance I was able to use a for loop to resolve it for( I=2; I<25; I+=2){ console.log(i); }
Steven Parker
231,275 PointsSteven Parker
231,275 PointsThe "do" loop would have also worked with the same loop body.
Glad I could help. And happy holidays!