lnr/Originals/Website/games/number/numbers.js
2021-04-15 17:26:34 -07:00

34 lines
822 B
JavaScript
Executable File

var guessme=Math.round(Math.random()*(99)+1);
var speech='Guess my number (from 1 to 100)';
function process(mystery) {
var guess=document.forms.guessquiz.guess.value;
var speech='"'+guess+ '" does not make sense to me.';
document.forms.guessquiz.guess.value='';
if (guess==mystery)
{
document.forms.guessquiz.prompt.value='Congratulations! '+mystery+' is correct!';
alert ('Well done - the mystery number is '+mystery+'! \n\nPress this button to reload the page for another game.');
speech='';
document.location=document.location;
}
if (mystery<guess)
{
speech='Less than '+ guess;
}
if (mystery>guess)
{
speech='Greater than '+ guess;
}
if (guess=='')
{
speech='You didn\'t guess anything!'
}
document.forms.guessquiz.prompt.value=speech; document.forms.guessquiz.guess.focus();
}