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

JavaScript JavaScript Loops Working with 'for' Loops Refactor Code with a Loop

Javascript loop code challenge seems to be malfunctioning

It keeps telling me that the even numbers are not all being logged, but when I check the console they're all there?

script.js
for (let i = 2; i <= 24; i += 2) {
console.log(`${i}`);
}

1 Answer

Rohald van Merode
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Rohald van Merode
Treehouse Staff

Hi Shaunty McMillin 👋

While your code should indeed be working perfectly the test that has been set up for this challenge doesn't like the template literal you're using. Simply logging i to the console should give you the same result and should pass the test for this challenge 😄

for (let i = 2; i <= 24; i += 2) {
  console.log(i);
}

That makes sense. I'm just so used to putting in additional context when I log things that I did a template literal reflexively. Thank you for explaining!