Last active
June 1, 2018 00:15
-
-
Save gladchinda/989eaec54e897fc12d424aab1464303f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var MIN_VALUE = 1; | |
| var MAX_VALUE = 5; | |
| /** | |
| * boundedValue(val) | |
| * | |
| * Returns val if val between MIN_VALUE and MAX_VALUE both inclusive | |
| * | |
| * Otherwise, returns MIN_VALUE if val is less than MIN_VALUE | |
| * | |
| * Else, returns MAX_VALUE if val is greater than MAX_VALUE | |
| */ | |
| function boundedValue(val) { | |
| return Math.max(MIN_VALUE, Math.min(MAX_VALUE, val)); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment