<script>
console.log(isInt(2.2));
console.log(isInt(2));
console.log(isInt(-4));
console.log(isInt(0.22));
function isInt(num){
if(num % 1 === 0) return true;
return false;
}
</script>
Result:
Reference:
https://stackoverflow.com/questions/14636536/how-to-check-if-a-variable-is-an-integer-in-javascript
No comments :
Post a Comment