Simple Calculator Lab

Easy
2
50.0% 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

  1. Create two input elements that accept numbers having ids input1 and input2
  2. Create four buttons having the following Id's and proper text inside them
  • addBtn for Adding
  • subtractBtn for Substraction
  • multiplyBtn for Multiplication
  • divideBtn for Divsion
  1. Create a div with id result that displays the output of the performed operations
  2. 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
  3. 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