community :)
I'm building a webpage and I need to show prices from external javascript variables into HTML table. Variables are declared like this:
var price1 = 256.6;
var price2 = 220.36;
Then I write these variables into HTML with internal script using .innerHTML() function. What I want is to make all variables in external javascript have 2 decimal points. I can use:
var price11 = price1.toFixed(2);
var price22 = price2.toFixed(2);
But I have too many variables to apply the conversion to each of them individually. So is there a way to convert all the variables on the entire script to have two decimal points?
As I know there is no way of doing that in core Javascript. You may have to write a on load function or some times there may be libraries to do that. But you will have to find hard for that.