-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
24 lines (19 loc) · 1.13 KB
/
Copy pathscript.js
File metadata and controls
24 lines (19 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
const delbutton = document.querySelector(".del"); //for delete button
const clrbutton = document.querySelector(".ac");
const eqbutton = document.querySelector(".eq");
delbutton.addEventListener("click",dele); //event on clicking delete button
clrbutton.addEventListener("click",clrscr); //event on clicking clear all button
eqbutton.addEventListener("click",calculate); //event on clicking equal to button
function display(e) { //function to diplay the value
document.getElementById("output").value+=e;
}
function clrscr(){ //functon of clear all
document.getElementById("output").value ="";
}
function calculate(){ //function to calculate
const ans = eval(document.getElementById("output").value);
document.getElementById("output").value=ans;
}
function dele(){ //function to delete latest input from user
document.getElementById("output").value=document.getElementById("output").value.substr(0,document.getElementById("output").value.length-1);
}