-
Notifications
You must be signed in to change notification settings - Fork 0
/
hc.js
38 lines (38 loc) · 1.06 KB
/
hc.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
$(document).ready(function() {
var answer = Math.floor(Math.random() * 10) +1;
console.log(answer);
$("#game").on("submit", function(){
event.preventDefault();
var guess = $("#guess").val();
console.log("Heading to Check!")
if (guess == answer) {
$("#bg").animate({
backgroundColor: "#F3FF00"
})
}
else if (Math.abs(answer - guess) <= 3) {
console.log("Within 3 block")
$("#bg").animate({
backgroundColor: "#FF0000"
}, 1000 );
console.log("You guessed within three.");
}
else if (Math.abs(answer - guess) <= 12) {
console.log("Within 12 block")
$("#bg").animate({
backgroundColor: "#AB00C2"
}, 1000 );
console.log("You guessed within twelve.");
}
else if (Math.abs(answer - guess) <= 24) {
console.log("Within 24 block")
$("#bg").animate({
backgroundColor: "#0084FF"
}, 1000 );
console.log("You guessed within twenty four.");
}
else {
console.log("Ending now!");
}
});
});