JSFiddle - React, Tailwind, and code Playground

JavaScript

var i = "1234";
function myToFixed(i, digits) {
    var pow = Math.pow(10, digits);
    return Math.floor(i * pow) / pow;
}
var xxx = myToFixed(i, 2)
alert(xxx);