Open this example in the interactive library
Source code
const close = (a, b, tolerance = 1e-9) => Math.abs(a - b) <= tolerance;
console.log(close(0.1 + 0.2, 0.3));
Sample output
true

Compare floating values. A self-contained example using the JavaScript runtime.
Open this example in the interactive library
const close = (a, b, tolerance = 1e-9) => Math.abs(a - b) <= tolerance;
console.log(close(0.1 + 0.2, 0.3));
true