JSFiddle - React, Tailwind, and code Playground

JavaScript

var nums = [
    "12345678910111.12", // -> 140.234
    "1.1123", // -> 1.123
    "-12.7789" // -> -12.790
];

nums.forEach(function(n) {
    console.log(parseFloat(n).toFixed(2));
});