Skip to content
Share
Explore

JavaScript Calculator


Starter Code: You need to fix this up to make it work:

<!DOCTYPE html> <html> <body> <form> <hr> <label for="inputa">Input A:</label> <input type="text" id="inputa" > <hr> <label for="inputa">Input B:</label> <input type="text" id="inputb" > <hr> <label for="inputa">Output:</label> <input type="text" id="output" > <hr> </form>
<button id="addButton">Add</button>
<script> document.getElementById("addButton").addEventListener("click", function() { var inputA = parseFloat(document.getElementById("inputa").value); var inputB = parseFloat(document.getElementById("inputb").value); var output = inputA + inputB; document.getElementById("output").value = output; });
</script> </body> </html>
Want to print your doc?
This is not the way.
Try clicking the ··· in the right corner or using a keyboard shortcut (
CtrlP
) instead.