Hacker News new | ask | show | jobs
by amichal 2127 days ago
Assuming we know (lower_bound <= upper_bound) I'd write:

Math.max(lower_bound, Math.min(num, upper_bound))

Since i read right to left.

1 comments

It’s amazing what a difference it makes when you just good names and formatting