Skip to content

Latest commit

 

History

History
17 lines (12 loc) · 400 Bytes

Array Map.md

File metadata and controls

17 lines (12 loc) · 400 Bytes

Array Map

Write a function named map that takes two arguments. arr (array) callback (function)

Return a new array where each element of arr is transformed by the callback function and the result is pushed into the new array.

For example:

var rounded = map([0.01, 2, 9.89, Math.PI], function(num) {
  return Math.round(num);
});

console.log(rounded); // [0, 2, 10, 3]