Skip to content

Instantly share code, notes, and snippets.

@adityasharat
Created May 5, 2015 13:18
Show Gist options
  • Save adityasharat/c83386ba0ce222061b67 to your computer and use it in GitHub Desktop.
Save adityasharat/c83386ba0ce222061b67 to your computer and use it in GitHub Desktop.
Create a Math Utility
var Math = {};
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/E
Math.E = 2.718;
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/max
Math.max = function (x, y) {
if (x > y) {
return x;
} else {
return y;
}
};
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/PI
Math.PI =
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/abs
Math.abs =
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/ceil
Math.ceil =
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/floor
Math.floor =
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/min
Math.min =
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/pow
Math.pow =
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/round
Math.round =
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment