Topic: Javascript Math object essentials
Javascript Math object is used to perform tasks like generating random numbers and evaluating constants like Pi.
(function() {
console.log('Value of Pi: ' + Math.PI);
console.log('Random number 0-6: ' + Math.floor(Math.random() * 6));
console.log('Random number 1-6: ' + Math.ceil(Math.random() * 6));
})();
Here too I am using Nodejs and closures.
Note that floor is used to generate random numbers starting from 0; where as ceil is used to generate random numbers starting from 1.
More on Math object available from MDN https://developer.mozilla.org/en-US/doc … jects/Math