Why does '0.1 + 0.2' not equal '0.3' in javascript?

Due to the way floating-point arithmetic works in most programming languages, including JavaScript, `0.1 + 0.2` doesn't exactly equal `0.3`. Example:

let result = 0.1 + 0.2;
console.log(result === 0.3);  // false
Solution:

let result = 0.1 + 0.2;
console.log(Math.abs(result - 0.3) < Number.EPSILON);  // true
You can use the `Number.EPSILON` to check if two numbers are approximately equal.

Beginner's Guide to JavaScript