Transforming Arrays with Array.map() in Javascript


Create a new array by applying a function to every element of an array.

Source Code

let numbers = [1, 2, 3, 4, 5];
let squares = numbers.map(number => number * number);
console.log(squares); // [1, 4, 9, 16, 25]
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments