Read the question, write JavaScript on the right, then Run or Check.
QuestionHint and solution stay closed until you open them
Read integers. Log the minimum and maximum separated by a space.
Input. Space-separated integers.
Output. min max
Examples
Input
3 1 8 2
Output
1 8
Hint
- Math.min(...nums) and Math.max(...nums)
Show correct code
Peek only after you have tried. You can still Check your own version.
const nums = readLine().trim().split(/\s+/).map(Number);
console.log(Math.min(...nums) + ' ' + Math.max(...nums));
main.jsconsole.log · readLine() · Ctrl + Enter
ResultIdle
Run to see output. Check grades the tests.