Min, max and average
Read a line of numbers separated by spaces. Print three lines: the smallest, the largest, and the average rounded to 2 decimal places.
Use toFixed(2) for the average.
Input
4 8 15 16 23 42
Expected output
4 42 18.00
Input
5
Expected output
5 5 5.00
Show a hint
Math.min(...nums) spreads the array into separate arguments. reduce adds them up for the average.
Show a solution
Loading the editor…
Run the tests to check your solution.