From 5529eb1781567df43b252d0558769d06c11f7dfe Mon Sep 17 00:00:00 2001 From: Om Duragkar Date: Sun, 3 Oct 2021 00:08:31 +0530 Subject: [PATCH] added back button so as to make calculator more productive --- app.js | 18 ++++++++++++++---- index.html | 1 + 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/app.js b/app.js index 9af1c56..1da4745 100644 --- a/app.js +++ b/app.js @@ -1,8 +1,8 @@ (function(){ - let screen = document.querySelector('.screen'); + let screen = document.querySelector('.screen'); let buttons = document.querySelectorAll('.btn'); - let clear = document.querySelector('.btn-clear'); + let clear = document.querySelector('.btn-clear'); let equal = document.querySelector('.btn-equal'); //retrieve data from numbers that are clicked @@ -13,7 +13,7 @@ }) }); - equal.addEventListener('click', function(e){ + equal.addEventListener('click', function(e){ if(screen.value === ''){ screen.value = 'Please Enter a Value'; } else { @@ -22,8 +22,18 @@ } }) - clear.addEventListener('click', function(e){ + clear.addEventListener('click', function(e){ screen.value = ''; }) + back.addEventListener('click', function(e){ + console.log(screen.value) + if(screen.value) + { + let o = screen.value; + let d = (eval(o)/10); + o=Math.floor(d); + screen.value = o; + } + }) })(); diff --git a/index.html b/index.html index 9a33797..d0a88ae 100644 --- a/index.html +++ b/index.html @@ -33,6 +33,7 @@ +