Math.random();
Result:
function getRandomIntInclusive(min, max) {
min = Math.ceil(min);
max = Math.floor(max);
return Math.floor(Math.random() * (max - min + 1) + min);
//The maximum is inclusive and the minimum is inclusive
}
getRandomIntInclusive(5, 20)
Result:
Math.PI;
Result:
function calculateCircumference(radius) {
return Math.PI * (radius + radius);
}
calculateCircumference(10);
Result:
Returns the square root of the sum of squares of its arguments. Can be used to get distance between 2 x,y coordinates
function getDistance(x1, x2, y1, y2) {
return Math.hypot(x2-x1, y2-y1);
}
getDistance(12,30,18,60);
Result:
Math.ceil(7.12345);
Result:
Math.floor(7.12345);
Result: