highAndLow 7kyu
codewars 7
by trentHarlem
JavaScript
function highAndLow(numbers) {
const sorted = numbers.split(' ').sort((a, b) => b - a)
const len = sorted.length - 1
return [sorted[0], sorted[len]].join(' ')
}
highAndLow("1 2 3 4 5"); // return "5 1"
highAndLow("1 2 -3 4 5"); // return "5 -3"
highAndLow("1 9 3 4 -5"); // 9 -5