1

I have the following routine in a script tag.

 for (var i = 0, j = message.Transactions.length; i < j; i++) { var m = message.Transactions[i]; //m.Amount Needs to be Currency IndexViewManager.displayList.push(m); } 

There's an element in "m" that is numeric and I want it to be displayed as currency. KnockoutJS is being utilized to data-bind the elements if that helps.

1 Answer 1

1

You can make use of the toLocaleString method and pass in the currency information as a object which is one of the input parameter to the method.

var number = 1234; console.log(number.toLocaleString('en-US', { style: 'currency', currency: 'USD' }));

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.