-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
50 lines (49 loc) · 1.28 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
window.addEventListener('load',()=>{
var app = new Vue({
el: '#app',
data: {
gelsayı:'',
gidensayı:'',
gidenbasamak:[],
gelbasamak:[],
started:false,
sonuc:'',
i:null,
sayac:0,
bilgi:'',
oran:0,
renk:'',
},
methods:{
start:function(){
this.started=true;
while(this.i<4) {
this.gelsayı += (Math.floor((Math.random()*9)+1)).toString() ;
this.i++;
}
this.gelbasamak=this.gelsayı.split('');
},
guess:function(){
this.sonuc='';
this.sayac++;
this.gidenbasamak=this.gidensayı.split('');
for (this.i = 0; this.i < 4; this.i++) {
if (this.gelbasamak[this.i]==this.gidenbasamak[this.i]) {
this.sonuc += '+';
this.oran=((100/4)*(this.sonuc.length))+'%';
if (this.oran=='25%') {this.renk='red';}
if (this.oran=='50%') {this.renk='yellow';}
if (this.oran=='75%') {this.renk='#4bff00';}
if (this.oran=='100%') {this.renk='#34b100';}
}
if(this.sonuc=='++++'){
this.bilgi=`Tebrikler, ${this.sayac} adımda tamamladınız... Sayınız ${this.gelsayı}`;
this.sonuc='';
}
}
this.i++;
},
}
}
)
})