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 trialsami thakur
970 Pointswhat does it mean by undefined numbers? it works normally if i use it on workspace i think
?
var stimpy = 2;
while(stimpy > 24){
stimpy += 2
console.log(stimpy);
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JavaScript Loops</title>
</head>
<body>
<script src="script.js"></script>
</body>
</html>
2 Answers
John Hill
Front End Web Development Techdegree Graduate 35,236 PointsSince stimpy is set to 2, it will never be greater than 24 and the while loop will not run.
Maybe you meant to use the less than symbol?
Michael Hulet
47,913 PointsThe checker itself appears to be written in JavaScript. When you or the checker encounters an error of some kind, its internal variable for the count of numbers you've printed is undefined
, so that's what it puts into the error message. In your case, you're printing 0 numbers to the console, because the code inside your loop will never run. My suggestion is to use a different operator in the condition of your while
loop
Michael Hulet
47,913 PointsMichael Hulet
47,913 PointsIt'd be important to use the less that or equals operator here. Either that or compare against
25
instead of24