diff options
-rwxr-xr-x | 2635/main.js | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/2635/main.js b/2635/main.js new file mode 100755 index 0000000..decd7d9 --- /dev/null +++ b/2635/main.js @@ -0,0 +1,17 @@ +#!/usr/bin/env node +"use strict"; + +/** + * * @param {number[]} arr + * * @param {Function} fn + * * @return {number[]} + * */ +var map = function (arr, fn) { + var resArr = new Array(); + var i = 0; + arr.forEach((element) => { + resArr.push(fn(element, i)); + i++; + }); + return resArr; +}; |