milanSumToZero vs sumToZero

Edit on GitHub

Setup

Tests

  • milanSumToZero

    var record = 10;
    function sumNumber (record) {
    	return (record * (record + 1 )) / 2;
    }
  • sumToZero

    var no = 10;
    function addToZero (no) {
      no > 0 ? return  [no, addToZero(no-1)].reduce((prev, current) => prev + current, 0) : 0;
    }