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
  • 53,428
  • 11
  • 128
  • 150
Kent Miller
  • 499
  • 2
  • 8
  • 21

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,538
  • 2
  • 25
  • 30