diff options
author | terminaldweller <devi@terminaldweller.com> | 2024-01-03 22:48:38 +0000 |
---|---|---|
committer | terminaldweller <devi@terminaldweller.com> | 2024-01-03 22:48:38 +0000 |
commit | 5d36918d7a229b8d987b242ff3fc3c9d4cfe6fbd (patch) | |
tree | 321b01b3c83a269678aad3469fd17a8127bc7aa9 | |
parent | 2665 (diff) | |
download | leetcode-5d36918d7a229b8d987b242ff3fc3c9d4cfe6fbd.tar.gz leetcode-5d36918d7a229b8d987b242ff3fc3c9d4cfe6fbd.zip |
2635
-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; +}; |