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 trialjohnny louifils
Full Stack JavaScript Techdegree Graduate 18,926 PointsHow do you put the push method in this code
Every time I try to put the push method in the times3 array it telling to restart my work
const numbers = [1,2,3,4,5,6,7,8,9,10];
let times5 = [];
numbers.forEach(function(times5) {
})
// times5 should be: [5,10,15,20,25,30,35,40,45,50]
// Write your code below
1 Answer
johnny louifils
Full Stack JavaScript Techdegree Graduate 18,926 PointsI still don't get though where do I put it
Ben Payne
1,464 PointsHey - no worries. Try this:
let numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
let times5 = [];
numbers.forEach(function(number) {
// Multiply the number times 5.
number = number * 5;
// Push the number onto the array.
times5.push(number);
});
Ben Payne
1,464 PointsBen Payne
1,464 PointsHey Johnny - In the closure you're going to get a number from the
numbers
array. Then inside that closure, you'll multiply times 5 and push the result onto thetimes5
array.Cheers
_Ben