Created
October 15, 2014 02:21
-
-
Save nw/1f44abe5a3a7ed59a633 to your computer and use it in GitHub Desktop.
hi low game
This file contains hidden or 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 num; | |
var guesses = 0; | |
function newGame(min, max) { | |
num = getRandomInt(min, max); | |
guesses = 0; | |
} | |
function guess(myGuess){ | |
guesses++; | |
if(myGuess == num){ | |
console.log("it took you " + guesses + " guesses"); | |
} else if( myGuess > num ) { | |
console.log("lower"); | |
} else { | |
console.log("higher"); | |
} | |
} | |
function getRandomInt(min, max) { | |
return Math.floor(Math.random() * (max - min)) + min; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment