Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function solve (arr) {
- let sum = arr.map(Number).reduce((a, b) => a + b, 0)
- let maxElement = +Math.max(...arr)
- let diff = Math.abs(sum - maxElement * 2)
- console.log(diff === 0 ? `Sum = ${maxElement}` : `No, Diff = ${diff}`)
- }
- solve(['2', '10', '90', '60', '40'])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement