sum of all numbers in an array javascript
const arrSum = arr => arr.reduce((a,b) => a + b, 0)
sum of all numbers in an array javascript
const arrSum = arr => arr.reduce((a,b) => a + b, 0)
sum all numbers in a range javascript
ar sum = 0;
for (var i = Math.min(...arr); i <= Math.max(...arr); i++) {
sum += i;
}
sum range javascript
function sumAll(arr) {
let fullArr = [];
let sum = 0;
const reducer = (accumulator, currentValue) => accumulator + currentValue;
arr.sort(function(a, b) {
return a - b
});
for (let i = arr[0]; i <= arr[1]; i++) {
fullArr.push(i);
}
sum = fullArr.reduce(reducer);
return sum;
}
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us