|
|
|
|
|
by 6510
617 days ago
|
|
If it needs to be fast use oldskool for() loops. function processfor(input){
let sum = 0
for (let i = 0; i < input.length; i++){
if (input[i] % 2 !== 0){ continue }
sum += input[i] * 2
}
return sum
}
https://jsfiddle.net/gaby_de_wilde/y7a39r15/5/ |
|
Of course, if you want the most performant solution an imperative for loop is faster (which is what I said in my last comment).