lib/sugar.js
/*
  This function receives an object, whose values will all be numbers, and returns the sum of all these numbers.
*/
This function receives an object, whose values will all be numbers, and returns the sum of all these numbers.
This function receives an object whose values will all be numbers and returns the sum of all these numbers .
function sum(object) {
  const objValues = Object.values(object);
  if(objValues.length === 0 ){
     return 0; 
  }
  return objValues.reduce((acc, value) => {
    if(typeof value === 'number') {
      return acc += value;
    } else {
      return acc += 0;
    }
  }, 0); 
}
function sum ( object ) { const objValues = Object . values ( object ) ; if ( objValues . length === 0 ) { return 0 ; } return objValues . reduce ( ( acc , value ) => { if ( typeof value === 'number' ) { return acc += value ; } else { return acc += 0 ; } } , 0 ) ; }
This function receives an object, whose values will all be numbers, and returns the sum of all these numbers.
This function receives an object whose values will all be numbers and returns the sum of all these numbers .
//create array of the obj values //check if array is empty, return 0 if yes //if not empty sum only the numbers values, if none return 0