Advertisement
nikolayneykov

Untitled

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