-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
79 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
alert(`Instructions to play | ||
• Check the number on top box and remember it . | ||
•Click on ready if you are ready | ||
•Enter the number in the input field | ||
•Everytime number of digits increase by 1 | ||
•You can answer only after clicking on Ready ! | ||
•Best of luck :)`) | ||
|
||
window.onload = () => { | ||
$("#button").hide(); | ||
var score = 0; | ||
var time_ = 5000; | ||
var num_2 = document.getElementById("num").value; | ||
num_2 ="0"; | ||
document.getElementById("num").innerHTML = num_2; | ||
document.getElementById("button").addEventListener("click",number) | ||
document.getElementById("button2").addEventListener("click",hidenum) | ||
|
||
document.getElementById("ans").disabled = true; | ||
document.getElementById("btn").addEventListener("click",restart) | ||
function restart(){ | ||
$("#button2").fadeIn(); | ||
$("#button").hide(); | ||
num_2 = "0"; | ||
score = 0; | ||
$("#score").html("Score : 0") | ||
document.getElementById("num").innerHTML = "0"; | ||
document.getElementById("body").style.display = "flex"; | ||
document.getElementById("card").style.display = "none"; | ||
|
||
} | ||
function number(){ | ||
document.getElementById("num").style.color="#fff"; | ||
num1 = document.getElementById("ans").value; | ||
if(num1 == num_2){ | ||
update(); | ||
} | ||
else{ | ||
lose(); | ||
} | ||
document.getElementById("ans").disabled = true; | ||
} | ||
function update(){ | ||
num_2 = num_2+Math.floor(Math.random()*9) | ||
document.getElementById("num").innerHTML = num_2; | ||
document.getElementById("ans").value = ""; | ||
score+= 10; | ||
document.getElementById("score").innerHTML = "Score : "+score; | ||
$("#button").hide(); | ||
$("#button2").fadeIn(); | ||
} | ||
function hidenum() { | ||
$("#button").fadeIn(); | ||
$("#button2").hide(); | ||
document.getElementById("num").style.color="#252525"; | ||
document.getElementById("ans").disabled = false; | ||
document.getElementById("ans").focus(); | ||
} | ||
function lose(){ | ||
document.getElementById("sco").innerHTML = "Score :" + score; | ||
document.getElementById("body").style.display = "none"; | ||
document.getElementById("card").style.display = "flex"; | ||
document.getElementById("ans").value =""; | ||
if(score == 0){ | ||
$("#iq").html("IQ : two mins of silence") | ||
}else if(score <= 30 && score >0){ | ||
$("#iq").html("IQ : Bad") | ||
}else if(score >=40 && score <=60){ | ||
$("#iq").html("IQ : Average") | ||
|
||
}else if(score >= 70 && score <= 100){ | ||
$("#iq").html("IQ : Good") | ||
} | ||
else{ | ||
$("#iq").html("IQ: Excellent") | ||
} | ||
|
||
} | ||
} |