Skip to content

Instantly share code, notes, and snippets.

@andreasonny83
Created June 17, 2018 09:04
Show Gist options
  • Save andreasonny83/ef2901568a9ca53f0ec6624b986fe66f to your computer and use it in GitHub Desktop.
Save andreasonny83/ef2901568a9ca53f0ec6624b986fe66f to your computer and use it in GitHub Desktop.
Array.prototype.mySum = function(callback) {
const vals = this;
const res = [];
for (var i = 0; i < vals.length; i++) {
res.push(callback(this[i]));
}
return res;
}
function cb(input) {
return input + 1;
}
const a = [1,2,3].mySum(x => cb(x));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment