Some calculations that involve floating point numbers ( a.k.a. decimal point) will not give you the answer that you expect. For example, 0.1 + 0.2 = 0.30000000000000004 . This is actually not the fault of Javascript , as most programming language have this same problem.
The reason behind this is because most programming language follow The IEEE Standard for Floating-Point Arithmetic (IEEE 754) to store floating point numbers, number like 0.2 actually only store the approximations to the value and not 0.2 . You can learn more here.