How to add floating point numbers in javascrtipt?

Problem

0.1 + 0.2 == 0.3 // false

Reason

0.1 + 0.2 // 0.30000000000000004

Solution

parseFloat( (0.1 + 0.2).toFixed(1) ) == 0.3 // true

You may also like...