-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
25 lines (24 loc) · 819 Bytes
/
Copy pathscript.js
File metadata and controls
25 lines (24 loc) · 819 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
var display=document.querySelector("input");
var buttons=document.querySelectorAll("button");
var btnArr=Array.from(buttons); /*Get the input datas in the form of a list*/
var inputData="";
btnArr.forEach(btn => {
btn.addEventListener('click',function(event){
if(event.target.innerHTML=="DEL"){
inputData=inputData.substring(0, inputData.length - 1);
display.value=inputData;
}
else if(event.target.innerHTML=="AC"){
inputData="";
display.value=inputData;
}
else if(event.target.innerHTML=="="){
inputData=eval(inputData);
display.value=inputData;
}
else{
inputData+=event.target.innerHTML;
display.value=inputData;
}
})
})