Skip to content

Instantly share code, notes, and snippets.

@stalukder03
Created July 19, 2019 03:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stalukder03/692875c7eae335ae547d40a1d0688ae2 to your computer and use it in GitHub Desktop.
Save stalukder03/692875c7eae335ae547d40a1d0688ae2 to your computer and use it in GitHub Desktop.
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