Q:

String toFixed with javascript?

I have a number which I needed to format as currency, to do this im having to turn my number into a string and run a function, This is working but its showing to X decimal places, Is it possible to use 'toFixed' on a string at all? I've tried with no luck and im unsure how to turn the string back into a number, I've used parseInt only it stops at the first character as it doesnt read past my delimeter...
var amount = String(EstimatedTotal);
var delimiter = ","; // replace comma if desired
var a = amount.split('.',2)
var d = a[1];
var i = parseInt(a[0]);
if(isNaN(i)) { return ''; }
var minus = '';
if(i < 0) { minus = '-'; }
i = Math.abs(i);
var n = new String(i);
var a = [];
while(n.length > 3)
{
    var nn = n.substr(n.length-3);
    a.unshift(nn);
    n = n.substr(0,n.length-3);
}
if(n.length > 0) { a.unshift(n); }
n = a.join(delimiter);
if(d.length < 1) { amount = n; }
else { amount = n + '.' + d; }
amount = minus + amount;

at the moment the amount variable showing as 1,234,567.890123
Thanks for the help all ,
Managed to get it working with this 
amount = String(EstimatedTotal) 

 amount += '';
x = amount.split('.');
x1 = x[0];
var rgx = /(\d+)(\d{3})/;
while (rgx.test(x1)) {
    x1 = x1.replace(rgx, '$1' + ',' + '$2');
}
num=x1 ;

A:

Not sure what you mean by currency-
this adds commas for thousands separators and forces two decimal places
input can be a string of digits with or without commas, minus sign and decimal, or a number
function addCommas2decimals(n){
    n= Number(String(n).replace(/[^-+.\d]+/g, ''));
    if(isNaN(n)){
        throw new Error('Input must be a number');
    }
    n= n.toFixed(2);
    var rx=  /(\d+)(\d{3})/;
    return n.replace(/^\d+/, function(w){
        while(rx.test(w)){
            w= w.replace(rx, '$1,$2');
        }
        return w;
    });

}
var s= '1234567.890123'
addCommas2decimals(s)

/*  returned value: (String)
1,234,567.89
*/

