Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- window.onload = () => {
- const calculator = document.forms.calculator
- calculator.addEventListener('click', (e) => {
- if (e.target) {
- if (e.target.matches("input.addon")) {
- calculator.display.value += e.target.value;
- } else if (e.target.matches('input#clear')) {
- calculator.display.value = '';
- } else if (e.target.matches('input#solve')) {
- calculator.display.value = eval(calculator.display.value)
- }
- }
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement