Q&A: How do I output currency ($) to a number in JavaScript?

Question by John: How do I output currency ($) to a number in JavaScript?
I am creating a website in JavaScript which after a product is selected it will add to the “shopping cart”, then once all the products are added, the shopping cart will calculate the price and the user can then check out, which will then open a new window called “check out” where the user adds their personal details. Everything is working fine all i want to do now is show a $ sign in front of all the prices.

Best answer:

Answer by Bryan
can you convert it to a string?

If so

var a = 5.00

var string = a.toString();

string = “$” + string;

What do you think? Answer below!

Leave a Reply

Your email address will not be published.

*

This site uses Akismet to reduce spam. Learn how your comment data is processed.