1
0
Fork 0
mirror of https://gitlab.com/mfocko/CodeWars.git synced 2024-09-08 01:26:57 +02:00
CodeWars/7kyu/highest_and_lowest/solution.js
Matej Focko fc899b0b02
chore: initial commit
Signed-off-by: Matej Focko <mfocko@redhat.com>
2021-12-28 16:19:58 +01:00

11 lines
298 B
JavaScript

function highAndLow(numbers){
numbers = numbers.split(' ');
let min = parseInt(numbers[0]),
max = parseInt(numbers[0]);
for (let i = 1; i < numbers.length; i++) {
let n = parseInt(numbers[i]);
if (n < min) min = n;
else if (n > max) max = n;
}
return `${max} ${min}`;
}