daily pastebin goal
76%
SHARE
TWEET

Untitled

kpdan95 Feb 16th, 2019 60 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const myArray = [1, 3, 5, 7];
  2.  
  3. function callback(elem, index, array) {
  4.   console.log({e: elem + 10, i: index - 1, arr: array});
  5. }
  6.  
  7. function myForEach(arr, callback){
  8.   for (let i = 0; i < arr.length; i++){
  9.     callback(arr[i], i, arr);
  10.   }
  11. }
  12.  
  13. const result = myForEach(myArray, callback);
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top