clear anything already in the log out of the way with the clear() funtion inside the console.
I’m not far more comfortable in the console.
Working with numbers
It is possible to round a number, or set a number to always roundup or always round down to the next whole integer, going against principles of math.
Here are some examples:
// unlike other js the Math starts of with a capital letter var num = 3.644545454 alert(Math.round(num)); alert(Math.floor(num)); alert(Math.ceil(num));
There are many more examples of the math object, another is the generation of a random number:
A random number will produce by default a number between 0 and 1 not including 1 a number with 16 decimal places like 0.6924692997708917.
Make this a whole number by passing the result of Math.random to Math.floor() or Math.ceil() multiply this number by another number (eg 7) to create a random number between 0 and 7. Add 1 so that number is between 1 and 10 by setting it to Math.floor() this will insure the number is rounded down to 10 and elimintes the chance of it being a 0.
//Create a random number Math.random(); //Create a whole Random number Math.floor(Math.random()); //Create a random number between one and 10 not including zero Math.floor(Math.random() * 10) + 1;