This is what I did, and it works every time.
var x= Number(54.03).toFixed(1);
if(Math.floor(x) == x) {
x = Math.floor(x);
}
alert( x );
I just compare these two types to see if they match. If they do, I know what may or may not be an extra zero. Anyway, I just round (ceil) or down (floor) and get an integer without annoying decimal and trailing zero.
source
share