Simple Calculator Lab
Easy
2
55.6% Acceptance
In this lab, you'll create a simple calculator capable of performing addition, subtraction, multiplication, and division operations. You'll have two input fields for receiving numerical inputs and four buttons for triggering the respective operations.
Upon clicking an operation button, the result will be displayed in a designated area on the page, and the input fields will be reset.
Steps
- Create two input elements that accept numbers having ids
input1
andinput2
- Create four buttons having the following Id's and proper text inside them
addBtn
for AddingsubtractBtn
for SubstractionmultiplyBtn
for MultiplicationdivideBtn
for Divsion
- Create a div with id
result
that displays the output of the performed operations - You have to create click event listeners for each button, whenever a button is specified the inputs should be read and the output of the performed operation should be displayed in the
result
div - Your code should handle division by Zero errors and any other edge cases that you might encounter.
Note: Your code is verified only by the output it produces in the
#result
element, make sure that you're adding the output the#result
div properly