I am trying to practice basic javascript on codepen so i made this basic calculator. when i click on the add button the correct answer is showing correctly on the browser but it suddenly disappears and i get not found error.
Here is my code:
let btn = document.getElementById("add")
let result = document.getElementById("result")
btn.addEventListener("click", () => {
let num1 = parseFloat(document.getElementById("num1").value);
let num2 = parseFloat(document.getElementById("num2").value);
result.innerHTML = num1 + num2
})
<form action="">
<h1>Add two numbers</h1>
<input id="num1" type="number" required>
<input id="num2" type="number" required>
<input type="submit" id="add" value="Add">
</form>
<div>
<h2 id="result"></h2>
</div>
I tried to check the console but i see nothing.