JAVASCRIPT   20

map

Guest on 1st May 2022 04:34:49 PM

  1. export default function map(arr, fn) {
  2.     var res = [],
  3.         i;
  4.     for (i = 0; i < arr.length; ++i) {
  5.         res.push(fn(arr[i], i));
  6.     }
  7.     return res;
  8. }

Raw Paste


Login or Register to edit or fork this paste. It's free.