-
-
Save Akifcan/8f328e266d7f3e1f4dbfc34aef4bdfec to your computer and use it in GitHub Desktop.
my map polypill
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const nums = [17, 1, 2, 3, -1] | |
const obj = (x) => { | |
return {initial: x, square: x*x, positive: Math.sign(x) > 0 ? true : false} | |
} | |
Array.prototype.myMap = function(cb){ | |
const output = [] | |
for(let i = 0; i<this.length; i++){ | |
output.push(cb(this[i])) | |
} | |
return output | |
} | |
console.log(nums.myMap(obj)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment