Created
September 4, 2014 18:14
-
-
Save imcodetolive/f4df8e0cfbdfbae30fed to your computer and use it in GitHub Desktop.
Constrain a number between two bounds
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
define(function(){ | |
"use strict"; | |
var constrain; | |
constrain = function(min, max){ | |
return function(number){ | |
return Math.max(min, Math.min(number, max)); | |
}; | |
}; | |
return constrain; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment