Implement a function clamp(number, lower, upper) that restricts a number to be within the inclusive lower and upper bounds.
The function should:
number: The number to clamplower: The minimum allowed valueupper: The maximum allowed valuelower if number < lowerupper if number > uppernumber if it is between lower and upperExample
clamp(5, 1, 10); // 5 clamp(-3, 0, 7); // 0 clamp(12, 0, 10); // 10
JavaScript Function
No test results yet
Click "Run" to execute tests