JSFiddle - React, Tailwind, and code Playground

by greatCar

JavaScript

function toFixed(num, fixed) {
    fixed = fixed || 0;
    fixed = Math.pow(10, fixed);
    return Math.floor(num * fixed) / fixed;
}
//alert(toFixed(4.56, 2));
let num = 4.56;
let floor  = Math.floor(num)
if(floor )

alert(Math.floor(4.56));