Skip to content

Commit

Permalink
Optimised the constrain function
Browse files Browse the repository at this point in the history
  • Loading branch information
samdbeckham committed Jul 9, 2014
1 parent e7279d7 commit ebcdf10
Showing 1 changed file with 1 addition and 7 deletions.
8 changes: 1 addition & 7 deletions Please.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,13 +175,7 @@
return Math.random() * (max - min) + min;
}
function constrain(num, min, max){
if (num < min) {
num = min;
}
else if(num > max){
num = max;
}
return num;
return Math.max(min, Math.min(num, max));
}
function convert_to_format(format_string, array){
switch(format_string){
Expand Down

0 comments on commit ebcdf10

Please sign in to comment.