JS - Math function
set of mathematical manipulations on items
Math.PI;
Math.round(num); ----> returns closest integer
Math.pow(a,b); ----> Returns a^b
Math.sqrt(num); ----> Returns Square Root
Math.abs(num); ----> Returns the absolute value
Math.ceil(num); ----> Returns the high next integer
Math.floor(num); ----> Returns the low next integer
Math.max(a, b, c, d); ----> Returns the highest value
Math.min(a, b, c, d); ----> Returns the lowest value
Math.random(); ----> Returns a value between 0 and 1
function randBetween(min,max){
max = Math.ceil(max);
min = Math.floor(min);
return Math.floor(Math.random() * (max-min)) + min;
}
var a = 6;
var b = 200;
console.log(randBetween(a,b));
back to main page