-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcalculator1.JS
37 lines (25 loc) · 876 Bytes
/
calculator1.JS
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
26
27
28
29
30
31
32
33
34
35
36
37
let del = document.getElementById('del');
del.addEventListener('click', deleteFromBack)
function deleteFromBack(){
var display1=document.getElementById('Display');
display1.textContent=display1.textContent.slice(0,-1);
console.log(display1.textContent);
}
function squareNum(value){
document.getElementById('Display').textContent +=value;
}
function clearDisplay(){
document.getElementById('Display').textContent='';
}
var display= document.getElementById('Display');
let square = document.getElementById('EXP');
// the square of a number function
square.addEventListener('click',square1)
function square1(){
display.textContent=parseInt(display.textContent)*parseInt(display.textContent)
}
let sqr1 =document.getElementById('squaroot');
sqr1.addEventListener('click', shift)
function shift(){
display.textContent= Math.sqrt(display.textContent)
}