Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const myArray = [1, 3, 5, 7];
- function callback(elem, index, array) {
- return {e: elem + 10, i: index - 1, arr: array};
- }
- function myMap(arr){
- const newArray = [];
- for (let i = 0; i < arr.length; i++){
- newArray.push(callback(arr[i], i, arr));
- }
- return newArray;
- }
- const result = myMap(myArray);
- console.log(result);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement