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 Array Iteration Methods Array Iteration Practice forEach()

Cristian Gerardo Hernandez Barrios
Cristian Gerardo Hernandez Barrios
28,382 Points

I need help with this code challenge, seems really easy but I'm stuck

I don't understand why I'm missing

app.js
const numbers = [1,2,3,4,5,6,7,8,9,10];
let times10 = [];

// times10 should be: [10,20,30,40,50,60,70,80,90,100]
// Write your code below
numbers.forEach(number => {
    times10.push
});

console.log(times10);

1 Answer

Greg Kaleka
Greg Kaleka
39,021 Points

Hi Gerado,

You're almost there, but inside your forEach method, you're not pushing anything! This would be equivalent to writing console.log with no arguments. Nothing would happen. push() takes one argument - the item you want to push onto the stack.

Once you fix your code so you're pushing something, make sure you're pushing the right thing. Remember what the challenge is asking you to push. Just think about the very first time through, and what you want to be in the first position of the array. How do you get that in there, using the local number variable, which will be the first item in numbers (the first time, anyway).

Happy coding :sparkles:

-Greg