I'm generating a PDF using code that includes some Javascript for calculating and displaying costs, but when I use Number.toLocaleString(), it returns "[object Number]" instead of the number as a string.
The code looks something like this:
Any idea why this wouldn't work as expected? I see toLocaleString() in the Javascript Support documentation, but it seems to be exhibiting the behavior of Object.toLocaleString() when it is NOT overridden for the Number object?
The code looks something like this:
var element = document.querySelector('.selector');
var cost = 5000.00;
element.textContent = cost.toLocaleString('en-US', { style: 'currency', currency: 'USD' });
// expected result: "$5,000.00"
// actual result: "[object Number]"
Any idea why this wouldn't work as expected? I see toLocaleString() in the Javascript Support documentation, but it seems to be exhibiting the behavior of Object.toLocaleString() when it is NOT overridden for the Number object?