JSFiddle - React, Tailwind, and code Playground

by hescano

JavaScript

function highAndLow(numbers){
  numbers = numbers.split(' ').map(function(i) { return Number(i); }).sort(function(a, b){return a- b;});
  return numbers[numbers.length - 1] + " " + numbers[0];
}

console.log(highAndLow("-1831 778 -981 -562 790 242 405 -2028 1045 -693 622 71 -238 638 -1643 543 28 -519 62 936 355"))