easy.math.random(max)
easy.math.random() returns a random number from 0 to "max"
syntax:
easy.math.random(max)
source code:
random(max) {
return Math.random() * max;
}
start and end:
arguments:
-
max (number):
the maximum number to be randomly generated
returns:
Math.random() * max
a random number, natively 0-1, multiplied by "max"
example:
easy.document.search("#button").addEventListener('click', () => {
window.alert(`your random number is ${easy.math.random(100)}`);
});
the example above...
- adds a click event listener to an element with "button" id (see easy.document.search(query) f)
- upon clicked, an alert opens, telling the user their random number
combos:
- easy.math.limit(numb, min, max) f can be used to form a random number within a certain range
heres an example:
easy.math.limit(easy.math.random(10), 5, 10)
- easy.math.integer(numb) f can be used to form a random integer instead
heres an example:
easy.math.integer(easy.math.random(10))