JSFiddle - React, Tailwind, and code Playground
HTML
<p id="demo">
</p>
JavaScript
function parseNumber(str) {
return parseFloat(str); // may return NaN, which should be handled by the caller!
}
function dropDecimalPart(num) {
return Math.trunc(num);
}
document.getElementById("demo").innerHTML = dropDecimalPart(4.6);