Ad

Yes, it is possible to reduce further for a cleaner result, but it will cost

Code
Diff
  • const addArr = arr => arr.length ? arr.reduce((acc, cur) => acc + cur, 0) : null 
    
    • const addArr = (arr) => {
    • let sum = 0;
    • for (let i = 0; i < arr.length; i++) {
    • sum += arr[i];
    • }
    • return sum || null;
    • };
    • const addArr = arr => arr.length ? arr.reduce((acc, cur) => acc + cur, 0) : null
Code
Diff
  • function formatIfNumber(value, numberOfPlaces) {
      return value / 2 ? Number(Math.round(value+'e'+numberOfPlaces)+'e-'+numberOfPlaces) : value; 
    }
    • function formatIfNumber(value, numberOfPlaces) {
    • if(value / 2) {
    • return Number(Math.round(value+'e'+numberOfPlaces)+'e-'+numberOfPlaces);
    • }
    • return value;
    • return value / 2 ? Number(Math.round(value+'e'+numberOfPlaces)+'e-'+numberOfPlaces) : value;
    • }