0

I am writing an application that outputs a price. My code for formatting the price is the following:

var preis_formatted = new Number(preis);
var preis_formatted = Number(preis_formatted.toFixed(2)).toLocaleString("nl-NL");

My problem: There are outputs like "26,4" where the 0 of decimals after the comma are not shown. How do I achieve that the output will be "26,40"?

Erik Philips
  • 51,408
  • 11
  • 123
  • 146
Kent Miller
  • 479
  • 2
  • 8
  • 20

1 Answers1

0

I think you misplaced the paren. This:

var preis_formatted = Number(preis_formatted.toFixed(2)).toLocaleString("nl-NL");

Should be this:

var preis_formatted = Number(preis_formatted).toFixed(2).toLocaleString("nl-NL");

And also you don't really need that toLocaleString.

zord
  • 4,355
  • 2
  • 27
  • 29