Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let solve = () => {
- let sum = arr => arr.reduce((a, b) => a + b)
- let min = arr => Math.min(...arr)
- let max = arr => Math.max(...arr)
- let product = arr => arr.reduce((a, b) => a * b)
- let join = arr => arr.join('')
- return { sum, min, max, product, join }
- }
- let aggregator = solve()
- console.log(aggregator.sum([1, 2, 3, 4, 5]))
- console.log(aggregator.min([1, 2, 3, 4, 5]))
- console.log(aggregator.max([1, 2, 3, 4, 5]))
- console.log(aggregator.product([1, 2, 3, 4, 5]))
- console.log(aggregator.join([1, 2, 3, 4, 5]))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement