programming-examples/js/Math/Check if a number is a whole number or has a decimal place.js
2019-11-15 12:59:38 +01:00

13 lines
333 B
JavaScript

function number_test(n)
{
var result = (n - Math.floor(n)) !== 0;
if (result)
return 'Number has a decimal place.';
else
return 'It is a whole number.';
}
console.log(number_test(25.66));
console.log(number_test(10));