Вот код, который вы хотите.
function formatMoney(n, c, d, t) {
var c = isNaN(c = Math.abs(c)) ? 2 : c,
d = d == undefined ? "." : d,
t = t == undefined ? "," : t,
s = n < 0 ? "-" : "",
i = String(parseInt(n = Math.abs(Number(n) || 0).toFixed(c))),
j = (j = i.length) > 3 ? j % 3 : 0;
return s + (j ? i.substr(0, j) + t : "") + i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + t) + (c ? d + Math.abs(n - i).toFixed(c).slice(2) : "");
}
function numShort(value){
if(value < 1000000){
return formatMoney(value, 2, ".", ",");
}else if(value < 1000000000){
return formatMoney((value/1000000), 2, ".", ",")+'m';
}else{
return formatMoney((value/1000000000), 2, ".", ",")+'b';
}
}
console.log(numShort(100));
console.log(numShort(1000));
console.log(numShort(10000));
console.log(numShort(100000));
console.log(numShort(1000000));
console.log(numShort(10000000));
console.log(numShort(100000000));
console.log(numShort(1000000000));
console.log(numShort(10000000000));
console.log(numShort(100000000000));