Highest and Lowest

PHOTO EMBED

Tue Oct 04 2022 09:56:35 GMT+0000 (Coordinated Universal Time)

Saved by @j_jivan #javascript

/*
In this little assignment you are given a string of space separated numbers, and have to return the highest and lowest number.
*/
function highAndLow(numbers){
  // 2147483648
  // ...
  let lo = 2147483648;
  let hi = -2147483648;
  numbers.split(" ").forEach(each=>{
    let num = Number(each);
    lo = Math.min(lo, num);
    hi = Math.max(hi, num);
  })
  return hi.toString() + " " + lo.toString();
}
content_copyCOPY

https://www.codewars.com/kata/554b4ac871d6813a03000035/train/javascript