-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
64 lines (62 loc) · 1.67 KB
/
app.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
let calculation = '';
function updateCalculation(userValue){
if(userValue == '1'){
calculation += '1';
showValues();
}else if(userValue == '2'){
calculation += '2';
showValues();
}else if(userValue == '3'){
calculation += '3';
showValues();
}else if(userValue == '+'){
calculation += '+';
showValues();
}else if(userValue == '4'){
calculation += '4';
showValues();
}else if(userValue == '5'){
calculation += '5';
showValues();
}else if(userValue == '6'){
calculation += '6';
showValues();
}else if(userValue == '-'){
calculation += '-';
showValues();
}else if(userValue == '7'){
calculation += '7';
showValues();
}else if(userValue == '8'){
calculation += '8';
showValues();
}else if(userValue == '9'){
calculation += '9';
showValues();
}else if(userValue == '*'){
calculation += '*';
showValues();
}else if(userValue == '0'){
calculation += '0';
showValues();
}else if(userValue == '.'){
calculation += '.';
showValues();
}else if(userValue == '/'){
calculation += '/';
showValues();
}else if(userValue == '='){
calculation = eval(calculation);
showValues();
}else if(userValue === 'clear'){
calculation = '';
showValues();
}
else if(userValue === '%'){
calculation += '%';
showValues();
}
}
function showValues(){
document.querySelector('.result').innerHTML = calculation;
}