I am attempting to convert a price from the database into a specific format, such as x,xxx.xx. For example, I want to display 1,000.55 instead of 1000.55. However, when I try to use the toLocaleString method in JavaScript, it does not produce the desired result.
Below is the function I have implemented in Vue.js:
formatProdPrice(value) {
return value.toLocaleString(['en-US', [{minimumFractionDigits: 2, maximumFractionDigits: 2}]]);
}
Here is how I am using this function:
formatProdPrice($page.price.price)
Even though I expect the output to be 1,000.55, the current output is 1000.55. Can anyone assist me in identifying what I may be doing incorrectly?