Question: I'd like to format numbers into the numbers next to them with k, lacs, crores in jQuery:

1000 to 1K

1500 to 1.5K

100000 to 1Lac

150000 to 1.5Lac

1000000 to 10Lac

10000000 to 1cr and so on !

```
<!DOCTYPE html>
<html>
<head>
    <title>Number Differentiation</title>
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
    <script type="text/javascript">
        $(document).ready(function(e){
              $('#numbr').bind('keypress', function (e) {
                                return (e.which != 8 && e.which != 0 && (e.which < 48 || e.which > 57) && e.which != 46) ? false : true;
              });
            $("#submitBut").click(function(e){

                alert(numDifferentiation( $("#numbr").val()))
            })
            function numDifferentiation($val){
               return $val;
            }
        })
    </script>
</head>
<body>
<input id="numbr" type="text"/>
<button id="submitBut">Click</button>
</body>
</html>

```

Answer: 
This should do it:

```
function numDifferentiation(val) {
    if(val >= 10000000) val = (val/10000000).toFixed(2) + ' Cr';
    else if(val >= 100000) val = (val/100000).toFixed(2) + ' Lac';
    else if(val >= 1000) val = (val/1000).toFixed(2) + ' K';
    return val;
}

```
You can also use the js inbuilt Intl library

```js
const formatter = new Intl.NumberFormat('en-IN', {
  style: 'currency',
  currency: 'INR',
  minimumFractionDigits: 0,
  maximumFractionDigits: 2,
  notation: 'compact',
  compactDisplay: 'long',
})

```

and use it like

```js
const value = 200000
formatter.format(value) // => 2L

```

One can optionally change the locale `en-IN` to `en-US` to suit their style of notations.

It will also round off your value to the nearest notation to make it look cleaner.