Hello,
I am writing a function to get the max and min numbers from the input (parameter).
The function works with no problem with the first code block below. The problem is it only works with a parameter that contains commas and now with a parameter such as ‘1 12 31’. The functions needs to be tested on parameters without commas. I have tried a number of things which haven’t worked, the latest of which is the tempComma var line included in the second text block below…
I know the tempComma var probably doesn’t make much sense, but not sure how to do this. Could someone give me a hint?
let tempComma = numbers.replace(/\s/g, ", ");
let tempArray = numbers.split(",").map(Number);
console.log(tempArray);
return `${Math.max(...tempArray)} ${Math.min(...tempArray)}`;
}
console.log(highAndLow("8 4 54"));
let tempArray = numbers.split(",").map(Number);
console.log(tempArray);
return `${Math.max(...tempArray)} ${Math.min(...tempArray)}`;
}