js-mentorship-razvan / javascript

Javascript study notes
GNU General Public License v3.0
22 stars 2 forks source link

Sum of two lowest positive integers #408

Closed RazvanBugoi closed 4 years ago

RazvanBugoi commented 4 years ago

https://www.codewars.com/kata/558fc85d8fd1938afb000014/train/javascript

RazvanBugoi commented 4 years ago
function sumTwoSmallestNumbers(numbers) {  
  return numbers.sort((a, b) => a - b)[0] + numbers.sort( (a, b) => a - b)[1];
}

What if one of the integers was negative?