Closed Emperor01 closed 6 years ago
added + before prompt and now if I input -2.4 I have -4.4
problem has been decided
xD
function getDecimal () { var num = +prompt('input number',''); var decimal; if (num > 0) { decimal = num - Math.floor(num); } else { decimal = num - Math.ceil(num); } decimal = Math.round(decimal * 1000) / 1000; return decimal; }
alert(getDecimal());
function getDecimal () { var num = prompt('input number',''); var decimal; if (num > 0) { decimal = num - Math.floor(num); } else { decimal = num + Math.ceil(num); } decimal = Math.round(decimal * 1000) / 1000; return decimal; }
alert(getDecimal());