I have an assignment to make a converter from decimal to binary numbers and vice versa. I have done everything I need, but I have no idea how to protect the site from the user entering a number with the part after the decimal point.
So I fooled around the internet and found Number.isInteger()
, yet I have no idea how this works. Tried writing some test stuff (as you can observe beneath this wall of text) but nothing seemed to work. Can anyone offer any help as to how exactly Number.isInteger() works?
pepege() {
var a = +document.getElementById("x").value;
var b = Number.isInteger(a);
document.getElementById("out").innerHTML = b;
}
<input type="text" id="x">
<br>
<input type="button" value="xddddd" onclick="pepege();">
<br>
<a id="out"></a>
Thanks for any and all advice on how to move forward with this.