Possible Duplicate:
Format numbers in javascript
I have a function that counts up, and I want to convert the number to a string and then add some commas and a decimal point. The problem is that I have no idea how to convert my number into a string and that add the necessary functionality within the given script that I have.
EDITTED: I'm not, by any means, a javascript programmer. Here's the code I'm working with, also here: http://jsfiddle.net/blackessej/TT8BH/6/
function createCounter(elementId,start,end,totalTime,callback)
{
    var jTarget=jQuery("#"+elementId);
    var interval=totalTime/(end-start);
    var intervalId;
    var current=start;
    var str = "" + start;
    var f=function(){
        jTarget.text(current);
        if(current==end)
        {
            clearInterval(intervalId);
            if(callback)
            {
                callback();
            }
        }
        ++current;
    }
    intervalId=setInterval(f,interval);
    f();
}
jQuery(document).ready(function(){
    createCounter("counter",12714086,9999999999,10000000000000,function(){
        alert("finished")
    })
})
function addCommas(str) {
    var amount = new String(str);
    amount = amount.split("").reverse();
    var output = "";
    for ( var i = 0; i <= amount.length-1; i++ ){
        output = amount[i] + output;
        if ((i+1) % 3 == 0 && (amount.length-1) !== i)output = ',' + output;
    }
    return output;
}
 
    