Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
var arr = [4,2,5,3];
function myRd(arr,callback){
var val=arr[0];
for(i=1;i<arr.length;i++){
val = callback(val,arr[i]);
}
return val;
}
var x = myRd(arr,function(a,b){
return a+b;
})
console.log(x);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment