alert( getDecimal(12.345) ); // 0.345
alert( getDecimal(1.2) ); // 0.2
alert( getDecimal(-1.2) ); // 0.2
alert( getDecimal(5) ); // 0
alert( getDecimal(1.3) ); // 0.3
function getDecimal(a) {
var b = Math.abs(a);
return +(b - Math.floor(b)).toFixed(10);
}
-
Вопрос задан
-
145 просмотров