JSFiddle - React, Tailwind, and code Playground
HTML
Type something in this input and on Enter it'll say if it's in an int or not<br>
<input type="text" onchange="document.getElementById('out').innerHTML=isInt(this.value);this.select()">
<span id="out"></span>
JavaScript
function assert(bool) {
if (!bool) throw "not true";
}
function isInt(x) {
var y = parseInt(x, 10);
return !isNaN(y) && x == y && x.toString() == y.toString();
}
assert(isInt("1"));
assert(isInt(1));
assert(!isInt("1a"));
assert(!isInt("1.0"));