These are chat archives for FreeCodeCamp/HelpFrontEnd

4th
Sep 2018
Morchid Chellali
@Morched23MJ
Sep 04 2018 09:58
Is there a better way to sum all values between an array containing two values than the following solution?
function sumAll(arr) {
    var sum = 0;
    for (var i = Math.min(...arr); i <= Math.max(...arr); i++){
        sum += i;
    }
  return sum;
}

sumAll([1, 4]);
Stephen James
@sjames1958gm
Sep 04 2018 10:09
Well there is a math formula for the sum of all numbers from m to n
(n(n+1) - m(m-1)) / 2
Morchid Chellali
@Morched23MJ
Sep 04 2018 10:12
That's better. :D Thanks
Tiago Correia
@tiagocorreiaalmeida
Sep 04 2018 10:59
anyone around who has used react-semantic-ui?