var lazyround = function (num) {
var parts = num.split(",");
return parts.length > 1 ? (Math.round(parseInt(parts.join(""), 10) / Math.pow(1000, parts.length-1)) + " " + ["thousand", "million", "billion"][parts.length-2]) : parts[0];
};
alert(lazyround("9,012,345,678"));
alert(lazyround("12,345,678"));
alert(lazyround("345,678"));
alert(lazyround("678"));
it outputs this:
9 billion
12 million
346 thousand
678
have fun. this works fine and since i dont see that you did anything yourself this is obfuscated.
there you have a working example in jsfiddle: jsfiddle.net/p8pfB/