Workshop › Pong › Step 10 of 26
A paddle must stop at the edges. clamp(value, min, max) squeezes a number into a range; we use it to keep each
paddle's y between 0 and canvas.height - PADDLE_H.
```js
function clamp(value, min, max) {
return Math.max(min, Math.min(max, value))
}
left.y = clamp(left.y, 0, canvas.height - PADDLE_H)
right.y = clamp(right.y, 0, canvas.height - PADDLE_H)
```Math.min(max, value) never lets the value above max; Math.max(min, ...) never below min.update, both paddles are squeezed between 0 and 320.function update, write clamp and an empty line.update, write the two clamp lines.Skills: Game states, Functions