Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

addition of var randomNumber #4

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 54 additions & 1 deletion js/app.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,55 @@

$(document).ready(function(){

var randomNumber = Math.floor(Math.random() * 100);
console.log(randomNumber);
var allGuesses = [];
var diff;
var message;
var guess;

$("#guessButton").click(function() {
var guess = $("#userGuess").val();
$("#userGuess").val('');
allGuesses.push(guess);
if (guess != '') {
$("#guessList").append("<li>" + guess + "</li>");
}
console.log('Guess = ' + guess);


diff = Math.abs(guess - randomNumber);

if (diff >= 80) {
message = "You're ice cold!"
}

else if ((diff >= 60) && (diff < 80)) {
message = "Very cold!"
}

else if ((diff >= 40) && (diff < 60)) {
message = "Cold!"
}

else if ((diff >= 20) && (diff < 40)) {
message = "Still pretty chilly!"
}

else if ((diff >= 11) && (diff < 20)) {
message = "You're warming up!"
}
else if ((diff >= 1) && (diff < 11)) {
message = "You're hot!"
}

else if (guess == randomNumber) {
message = "You got it!"
}

$("#feedback").text(message);
return false;


/*--- Display information modal box ---*/
$(".what").click(function(){
$(".overlay").fadeIn(1000);
Expand All @@ -12,6 +61,10 @@ $(document).ready(function(){
$(".overlay").fadeOut(1000);
});

});

});