svephoto

Aggregate Elements [JavaScript]

Aug 2nd, 2021
541
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. let aggregateElements = (array) => {
  2.     let numbersArray = array.map(Number);
  3.  
  4.     let sum = numbersArray.reduce((a, b) => a + b);
  5.     let inverseValuesSum = numbersArray.reduce((a, b) => a + 1 / b, 0);    
  6.     let stringConcat = numbersArray.join('');
  7.  
  8.     console.log(sum);
  9.     console.log(inverseValuesSum);
  10.     console.log(stringConcat);
  11. }
  12.  
RAW Paste Data