easy.math.integer(numb)
easy.math.integer() returns the argument "numb" as an integer, if it already isnt
syntax:
easy.math.integer(numb)
source code:
integer(numb) {
return Math.round(numb);
}
start and end:
arguments:
-
numb (number):
the number to be converted to an integer
returns:
Math.round(numb)
the "numb" argument rounded to an integer
example:
easy.document.search("#button").addEventListener('click', () => {
const response = window.prompt("enter a decimal");
window.alert(`${response} as an integer is ${easy.math.integer(response)}`);
});
the example above...
- adds a click event listener to an element with "button" id (see easy.document.search(query) f)
- upon clicked, a prompt is triggered under a const named "response", asking the user to enter a number
- after the prompt is closed, an alert opens, telling what the response as an integer is
combos:
none