[JavaScript] Math & Numbers

/* generates a random decimal number between 0 (inclusive) and up to 1 (exclusive). */
Math.random()

/* Round the number down to its nearest whole number. */
Math.floor()

/* x to the power of y */
Math.pow(num, 2)

/* Parse a string and return as integer. */
var int = parseInt("020"); // returns 20

/* Parse a string and return as float. */
var float = parseFloat("8.55"); // returns 8.55

/* Check if number is not float */
function isInt(n) {
   return n % 1 === 0;
}

Leave a Reply

Your email address will not be published. Required fields are marked *