Discussion

#148 clamp

easy
javascript

Implement a function similar to _.clamp from the Lodash library. The function clamp takes three arguments: a number, a lower bound, and an upper bound. The function returns the number clamped within the inclusive lower and upper bounds.

Example usage

console.log(clamp(10, 5, 15)); // 10

console.log(clamp(4, 5, 15)); // 5

console.log(clamp(20, 5, 15)); // 15