Advertisement
kpdan95

Untitled

Feb 16th, 2019
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.34 KB | None | 0 0
  1. const myArray = [1, 3, 5, 7];
  2.  
  3. function callback(elem, index, array) {
  4. return {e: elem + 10, i: index - 1, arr: array};
  5. }
  6.  
  7. function myMap(arr){
  8. const newArray = [];
  9. for (let i = 0; i < arr.length; i++){
  10. newArray.push(callback(arr[i], i, arr));
  11. }
  12. return newArray;
  13. }
  14.  
  15. const result = myMap(myArray);
  16. console.log(result);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement