Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var arr = [1,2,3,4]
- // arr.forEach(function(value, index, arr){
- // console.log(index, value, arr)
- // })
- function forEach(arr, func){
- for(var i = 0; i<=arr.length; i++){
- func(i,arr);
- }
- }
- var sum=0;
- forEach(arr, function(i, arr){
- console.log(i,arr);
- sum += i;
- });
- console.log(sum)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement