I saw this, and had to try it myself
Here's another way to do it. Probably worse than your solution. But I wanted to make it a chain of function calls
function sumTwoSmallestNumbers(numbers) {
return (numbers.sort((a, b) => a - b))
.slice(0, 2)
.reduce((prev, cur) => prev + cur)
}
I saw this, and had to try it myself
Here's another way to do it. Probably worse than your solution. But I wanted to make it a chain of function calls
function sumTwoSmallestNumbers(numbers) { return (numbers.sort((a, b) => a - b)) .slice(0, 2) .reduce((prev, cur) => prev + cur) }