Skip to content

Commit

Permalink
Highest and Lowerst
Browse files Browse the repository at this point in the history
  • Loading branch information
michaeltomasik committed Feb 26, 2019
1 parent 83efebb commit 203e61a
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions HighestAndLowest.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// https://www.codewars.com/kata/highest-and-lowest/

// In this little assignment you are given a string of space separated numbers, and have to return the highest and lowest number.
// Example:

// highAndLow("1 2 3 4 5"); // return "5 1"
// highAndLow("1 2 -3 4 5"); // return "5 -3"
// highAndLow("1 9 3 4 -5"); // return "9 -5"

function highAndLow(numbers){
const numbersArr = numbers.split(' ');
const min = Math.min(...numbersArr);
const max = Math.max(...numbersArr);

return max + ' ' + min;
}

0 comments on commit 203e61a

Please sign in to comment.