Answer the question
In order to leave comments, you need to log in
How to remove the computational error in an array?
Array.prototype.plusNext = function() {
return this.map(function(el, i, arr) {
return (
el + arr[i + 1]
)
})
}
Answer the question
In order to leave comments, you need to log in
You can try something like this (not a zhabist, so I can write with an error)
replace el + arr[i + 1] with
el + ( typeof arr[i + 1] != "undefined" ? arr[i + 1] : 0 )
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question