Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let aggregateElements = (array) => {
- let numbersArray = array.map(Number); // map
- let sum = numbersArray.reduce((a, b) => a + b);
- let inverseValuesSum = numbersArray.reduce((a, b) => a + 1 / b, 0); // reduce
- let stringConcat = numbersArray.join(''); // join
- console.log(sum);
- console.log(inverseValuesSum);
- console.log(stringConcat);
- }
- aggregateElements([2, 4, 8, 16]);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement