title


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:

  1. 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...

  1. adds a click event listener to an element with "button" id (see easy.document.search(query) f)
  2. upon clicked, a prompt is triggered under a const named "response", asking the user to enter a number
  3. after the prompt is closed, an alert opens, telling what the response as an integer is

combos:

none



see also:

  1. easy.document.search(query) f