-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
145 lines (109 loc) · 3.38 KB
/
index.html
File metadata and controls
145 lines (109 loc) · 3.38 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
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
body{
background-color: rgb(218, 199, 176);
text-align: center;
border: solid 5px rgb(157, 172, 190);
}
div#div1{
margin-top: 400px;
}
#div2true1{
background-color: rgb(113, 189, 113);
}
#div3false{
background-color: rgb(201, 89, 89);
}
</style>
</head>
<body>
<div id="div1">
<span id="number1">0</span>
<span id="number2">*</span>
<span id="operator">0</span>
<span>=</span>
<input type="number" id="textbox" placeholder="Değer Girin:" />
<button id="button11" onclick="button11()"> hesapla</button>
<div id="div2true1">0</div>
<div id="div3false">0</div>
<div style="clear: both" id="div4"></div>
</div>
<script>
var number1=document.getElementById("number1");
var number2=document.getElementById("number2");
var operator=document.getElementById("operator");
var button1=document.getElementById("button1");
var div4=document.getElementById("div4");
var div1=document.getElementById("div1");
var div2true1=document.getElementById("div2true1");
var div3false=document.getElementById("div3false");
function randomrandom(min,max){
var Number=Math.floor(Math.random()*(max-min))+min;
return Number;
}
function newquestion() {
operator2=["+","-","*","/"];
number2.innerHTML=operator2[randomrandom(0,4)];
//? çalışmassa hata burada */
number1.innerHTML=randomrandom(0,50);
operator.innerHTML=randomrandom(0,50);
if (number2.innerHTML=="/") {
while (true) {
operator.innerHTML=randomrandom(0,50);
if (number1.innerHTML%operator.innerHTML==0) {
break;
}
}
}
}
window.onload=function(){
newquestion();
}
function button11(){
var textbox=document.getElementById("textbox").value;
let n1=Number(number1.innerHTML);
let n2=Number(operator.innerHTML);
switch(number2.innerHTML){
case"+":
ans=Number(n1+n2);
console.log(ans);
break;
case"/":
ans=Number(n1/n2);
console.log(ans);
break;
case"-":
ans=Number(n1-n2);
console.log(ans);
break;
case"*":
ans=Number(n1*n2);
console.log(ans);
break;
default:break;
}
console.log("burası text box",textbox);
// console.log(textboxEl)
//aynı textcontent hatası burda da olabilir
if (textbox==ans) {
div2true1.innerHTML=Number(div2true1.innerHTML)+1;
}
else {
div3false.innerHTML=Number(div3false.innerHTML)+1;
}
while (textbox.getElementById==true) {
div2true1.innerHTML=Number(div2true1.innerHTML)+1;
}
//true ve false booleanlarını kullanmak yerine tanımladığım divdeki değerleri kullandım
console.log(ans);
newquestion();
//ans ile textboxu karşılaştır!!
}
</script>
</body>
</html>