lnr/Originals/Website/games/number/numbers.js

34 lines
822 B
JavaScript
Raw Permalink Normal View History

2021-04-16 00:26:34 +00:00
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();
}