-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcalculator.js
61 lines (46 loc) · 1.48 KB
/
calculator.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
let calculation = '';
function updateCalculation(playerMove){
if(playerMove===1){
calculation += 1;
}else if(playerMove===2){
calculation += 2;
}else if(playerMove===3){
calculation += 3;
}else if(playerMove==='+'){
calculation += '+';
}else if(playerMove===4){
calculation += 4;
}else if(playerMove===5){
calculation += 5;
}else if(playerMove===6){
calculation += 6;
}else if(playerMove==='-'){
calculation += '-';
}else if(playerMove===7){
calculation += 7;
}else if(playerMove===8){
calculation += 8;
}else if(playerMove===9){
calculation += 9;
}else if(playerMove==='*'){
calculation += '*';
}else if(playerMove===0){
calculation += 0;
}else if(playerMove==='.'){
calculation += '.';
}else if(eval(calculation)){
calculation =eval(calculation);
}else if(playerMove==='/'){
calculation +='/';
}else if(playerMove===clear){
inputElement.value ;
calculation = '';
}
//console.log(playerMove);
}
function appendToDisplay(playerMove) {
document.querySelector(".display").value += playerMove;
}
function clearDisplay() {
document.querySelector(".display").value="";
}