codewars-kata/JavaScript/seriesSum.js
/**
 * This 7 kyu kata (shorturl.at/ctuNR) presents a simple, predictable series of
 * shrinking numbers which are to be summed up and returned as a String.
 */
This 7 kyu kata (shorturl.at/ctuNR) presents a simple, predictable series of
shrinking numbers which are to be summed up and returned as a String.
This 7 kyu kata ( shorturl . at / ctuNR ) presents a simple predictable series of shrinking numbers which are to be summed up and returned as a String .
function seriesSum(n)
{
  if (n === 0) {
    return '0.00';
  }
  let sum = 1.00;
  for (let i = 1; i < n; i++) {
    sum += 1.00 / (1 + 3.00 * i);
  }
  return sum.toPrecision(3);
}
function seriesSum ( n ) { if ( n === 0 ) { return '0.00' ; } let sum = 1.00 ; for ( let i = 1 ; i < n ; i ++ ) { sum += 1.00 / ( 1 + 3.00 * i ) ; } return sum . toPrecision ( 3 ) ; }
This 7 kyu kata (shorturl.at/ctuNR) presents a simple, predictable series of
 shrinking numbers which are to be summed up and returned as a String.
This 7 kyu kata ( shorturl . at / ctuNR ) presents a simple predictable series of shrinking numbers which are to be summed up and returned as a String .