Advertisement
Guest User

Untitled

a guest
Jun 3rd, 2020
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. window.onload = () => {
  2.   const calculator = document.forms.calculator
  3.  
  4.   calculator.addEventListener('click', (e) => {
  5.     if (e.target) {
  6.       if (e.target.matches("input.addon")) {
  7.         calculator.display.value += e.target.value;
  8.       } else if (e.target.matches('input#clear')) {
  9.         calculator.display.value = '';
  10.       } else if (e.target.matches('input#solve')) {
  11.         calculator.display.value = eval(calculator.display.value)
  12.       }
  13.     }
  14.   });
  15. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement