Skip to content

Commit 08ef544

Browse files
committed
Create: 2635-apply-transform-over-each-element-in-array.js
1 parent 017f438 commit 08ef544

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/**
2+
* @param {number[]} arr
3+
* @param {Function} fn
4+
* @return {number[]}
5+
*/
6+
const map = (arr, fn) => {
7+
const result = [];
8+
for (let i = 0; i < arr.length; i++) {
9+
result.push(fn(arr[i], i));
10+
}
11+
return result;
12+
}

0 commit comments

Comments
 (0)