-
-
Save codecademydev/71da1ff389595a0af686e4fec4c680ef to your computer and use it in GitHub Desktop.
Codecademy export
This file contains 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
const _ = { | |
clamp(number, lower, upper) { | |
const lowerClampedValue = Math.max(number, lower); | |
const clampedValue = Math.min(lowerClampedValue, upper); | |
return clampedValue; | |
}, | |
inRange(number, start, end) { | |
if(end === undefined) { | |
end = start; | |
start = 0; | |
}; | |
if(start > end) { | |
const temp = end; | |
end = start; | |
start = temp; | |
}; | |
const isInRange = start <= number < end; | |
if(isInRange) { | |
return true; | |
} else { | |
return false; | |
} | |
} | |
}; | |
// Do not write or modify code below this line. | |
module.exports = _; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment