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 trial
ab199
Full Stack JavaScript Techdegree Student 20,137 PointsWhy isn't my JavaScript code passing? (Code Challenge: Refactor)
function evens(first, last) {
firstNumber = first;
lastNumber = last;
while (firstNumber <= lastNumber) {
console.log(firstNumber);
firstNumber += 2;
}
}
evens(2, 24);
I'm having a lot of trouble here. This is the error message I'm getting: Bummer! I don't see a loop in your code. Use a while, for, or do...while loop. (A for loop is easiest.). When I run this code in a console, it works as expected. Even numbers from 2 until 24 are printed to the console using the console.log command. What am I doing wrong here?
1 Answer
Aalia Naz
5,854 Pointsmay be its because you are using loop inside the function. try this one.. may be it will help..
var counter = 2; while ( counter <=24 ) { console.log(counter); counter += 2; }