js floating point
by Pedro Batista
HTML
<div>
<h1>According to JavaScript, what is the result of 0.3 - 0.2?</h1>
</div>
<hr />
<div id="response"></div>
<hr />
<h2>👌</h2>
JavaScript
const responseDiv = document.querySelector("#response");
const result = 0.3 - 0.2;
responseDiv.innerHTML = `
<div><strong>toString:</strong> ${result.toString()}</div>
<div><strong>toExponential:</strong> ${result.toExponential()}</div>
<div><strong>toPrecision:</strong> ${result.toPrecision()}</div>
`;