javascript - How to format float 0.5 to float 0.50 -


update: seem bug. github issue link: https://github.com/freecodecamp/freecodecamp/issues/10491

=================

i studying freecodecamp course-"exact change". need convert float-type-data 0.5 float-type-data 0.50, have try solutions not work!

float.tofixed(2) return string-type "0.50", , if use parsefloat("0.50") return float-type-data 0.5!

how can solve issue?

follow requirement screenshot, had try float 0.5, failed pass!

enter image description here

you have slight misconception numbers in javascript.

javascript numbers not have trailing zeroes after decimal point. if requirement 0.50 displayed on screen, must string "0.50", , not number, 0.5.


Comments

Popular posts from this blog

php - How to add and update images or image url in Volusion using Volusion API -

Laravel mail error `Swift_TransportException in StreamBuffer.php line 269: Connection could not be established with host smtp.gmail.com [ #0]` -

c# SetCompatibleTextRenderingDefault must be called before the first -