<!DOCTYPE html>
<html>
<head>
<title>Calculator</title>
</head>
<body>
<h2>Calculator</h2>
<input type="number" id="a" placeholder="First number">
<input type="number" id="b" placeholder="Second number">
<button onclick="add()">Add</button>
<p id="result"></p>
<script>
function add() {
let a = Number(document.getElementById("a").value);
let b = Number(document.getElementById("b").value);
document.getElementById("result").innerText =
"Result: " + (a + b);
}
</script>
</body>
</html>
Welcome to the forum @Apside,
I’ve edited your post for readability. Do you have a question about this code?
Happy coding