Hello Friends 👋,
Welcome To Infinitbility! ❤️
Many times, we have to convert numbers to decimals to show value more attractive and informative to the user.
toFixed() method to convert number spcfied decimal places.
If we pass
toFixed() method for
100 it will return
100.00 in string.
1let num : number = 100;2num.toFixed(2); // '100.00'
toFixed() method also helps to define decimal places like if we have
23.3476354 and you want to only two decimal places then also you can use it.
1let num : number = 23.3476354;2num.toFixed(2); // 23.35
it’s also rounding decimal places automatically.
Thanks for reading…
Follow me on Twitter
Join our email list and get notified about new content
No worries, I respect your privacy and I will never abuse your email.
Every week, on Tuesday, you will receive a list of free tutorials I made during the week (I write one every day) and news on other training products I create.