The above code would output 2.00. You can, of course, specify as many digits as you want like this:
You can also format a string with N decimal places. To do that, you’d first need to convert the string to a number. You can then chain the result with a toFixed() method as shown in the example below:
If you have any doubts or suggestions, let me know in the comments below!