[Solved] I have a number and I need to format it to billion or million


The toFixed() method converts a number into a string, keeping a specified number of decimals.
Here is the JsFiddle link
https://jsfiddle.net/zco2d5x1/

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);

0

solved I have a number and I need to format it to billion or million