Skip to content

Instantly share code, notes, and snippets.

@ilopX
Created November 12, 2019 17:33
Show Gist options
  • Save ilopX/b073772502455d1d52c825c40bf94f76 to your computer and use it in GitHub Desktop.
Save ilopX/b073772502455d1d52c825c40bf94f76 to your computer and use it in GitHub Desktop.
function listNum(operation) {
let oneNumber = parseInt(this.join(''))
return operation(oneNumber).toString()
.split('')
.map(val => new Number(val))
}
Array.prototype.increment = function() {
return listNum.call(this, (val) => ++val)
}
Array.prototype.decrement = function() {
return listNum.call(this, (val) => --val)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment