Created
March 31, 2015 12:42
-
-
Save zischwartz/886a3f6375b5806e2263 to your computer and use it in GitHub Desktop.
ScriptEd Unit 7 Project: Hi- Lo // source http://jsbin.com/lejewepeyo
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css" rel="stylesheet" type="text/css" /> | |
<link href="css/highlow.css" rel="stylesheet" type="text/css" /> | |
<script src="https://code.jquery.com/jquery-1.9.1.min.js"></script> | |
<script src="js/guts.js"></script> | |
<script src="js/highlow.js"></script> | |
<title>ScriptEd Unit 7 Project: Hi- Lo</title> | |
<style id="jsbin-css"> | |
.container | |
{ | |
max-width: 600px; | |
} | |
#check-btn | |
{ | |
margin-top: 20px; | |
} | |
#generate-btn | |
{ | |
margin: 20px; | |
} | |
</style> | |
</head> | |
<body> | |
<div class="container"> | |
<h1>ScriptEd Unit 7 Project: Hi-Lo</h1> | |
<hr/> | |
<div class="text-center"> | |
<button type="submit" id="generate-btn" class="btn btn-primary btn-lg">Generate random number</button> | |
<input type="text" class="form-control input-lg " id="guess" placeholder="Guess a number between 1 and 10"> | |
<button type="submit" id="check-btn" class="btn btn-success btn-lg">Check</button> | |
<br/> | |
<br/> | |
<div class="alert text-left" role="alert" id="correct">.</div> | |
</div> | |
</div> | |
<script id="jsbin-javascript"> | |
var guess_count = 0; | |
function generateRandomNumber() | |
{ | |
// YOUR CODE GOES HERE | |
return Math.ceil(Math.random()*10000); | |
} | |
function checkGuess(guess, generatedRandomNumber) | |
{ | |
guess_count++; | |
// guess_count = guess_count + 1; | |
// console.log(guess_count); | |
if (guess === generatedRandomNumber){ | |
alert('win'); | |
$('#generate-btn').show(); | |
$("#guess").val(""); | |
} | |
// else if (guess_count ==3) { | |
// alert('you loser!!'); | |
// } | |
// YOUR CODE GOES HERE | |
//INCLUDE THESE TWO LINES IN YOUR WIN CONDITION | |
} | |
//Don't edit. | |
$(document).ready(function(){ | |
var randomNum = 0; | |
$('#generate-btn').on("click", function(){ | |
randomNum = generateRandomNumber(); | |
console.log(randomNum); | |
$('#generate-btn').hide(); | |
}); | |
$('#check-btn').on("click", function(){ | |
var guess = parseInt($('#guess').val()); | |
checkGuess(guess, randomNum); | |
}); | |
}); | |
</script> | |
<script id="jsbin-source-css" type="text/css">.container | |
{ | |
max-width: 600px; | |
} | |
#check-btn | |
{ | |
margin-top: 20px; | |
} | |
#generate-btn | |
{ | |
margin: 20px; | |
}</script> | |
<script id="jsbin-source-javascript" type="text/javascript">var guess_count = 0; | |
function generateRandomNumber() | |
{ | |
// YOUR CODE GOES HERE | |
return Math.ceil(Math.random()*10000); | |
} | |
function checkGuess(guess, generatedRandomNumber) | |
{ | |
guess_count++; | |
// guess_count = guess_count + 1; | |
// console.log(guess_count); | |
if (guess === generatedRandomNumber){ | |
alert('win'); | |
$('#generate-btn').show(); | |
$("#guess").val(""); | |
} | |
// else if (guess_count ==3) { | |
// alert('you loser!!'); | |
// } | |
// YOUR CODE GOES HERE | |
//INCLUDE THESE TWO LINES IN YOUR WIN CONDITION | |
} | |
//Don't edit. | |
$(document).ready(function(){ | |
var randomNum = 0; | |
$('#generate-btn').on("click", function(){ | |
randomNum = generateRandomNumber(); | |
console.log(randomNum); | |
$('#generate-btn').hide(); | |
}); | |
$('#check-btn').on("click", function(){ | |
var guess = parseInt($('#guess').val()); | |
checkGuess(guess, randomNum); | |
}); | |
}); | |
</script></body> | |
</html> |
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
.container | |
{ | |
max-width: 600px; | |
} | |
#check-btn | |
{ | |
margin-top: 20px; | |
} | |
#generate-btn | |
{ | |
margin: 20px; | |
} |
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
var guess_count = 0; | |
function generateRandomNumber() | |
{ | |
// YOUR CODE GOES HERE | |
return Math.ceil(Math.random()*10000); | |
} | |
function checkGuess(guess, generatedRandomNumber) | |
{ | |
guess_count++; | |
// guess_count = guess_count + 1; | |
// console.log(guess_count); | |
if (guess === generatedRandomNumber){ | |
alert('win'); | |
$('#generate-btn').show(); | |
$("#guess").val(""); | |
} | |
// else if (guess_count ==3) { | |
// alert('you loser!!'); | |
// } | |
// YOUR CODE GOES HERE | |
//INCLUDE THESE TWO LINES IN YOUR WIN CONDITION | |
} | |
//Don't edit. | |
$(document).ready(function(){ | |
var randomNum = 0; | |
$('#generate-btn').on("click", function(){ | |
randomNum = generateRandomNumber(); | |
console.log(randomNum); | |
$('#generate-btn').hide(); | |
}); | |
$('#check-btn').on("click", function(){ | |
var guess = parseInt($('#guess').val()); | |
checkGuess(guess, randomNum); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment