JSFiddle - React, Tailwind, and code Playground
JavaScript
function fnum(x) {
if (x < 1000000000) {
alert((x / 1000000).toFixed(2) + "M");
} else if (x < 1000000000000) {
alert((x / 1000000000).toFixed(2) + "B");
} else
alert("More");
}
fnum(136866516683);