codetoad.com
  ASP Shopping CartForum & BBS
  - all for $20 from CodeToad Plus!
  
  Home || ASP | ASP.Net | C++/C# | DHTML | HTML | Java | Javascript | Perl | VB | XML || CodeToad Plus! || Forums || RAM 
Search Site:
Search Forums:
  Modifying a Basic Javascript Game  FatherShark at 04:52 on Monday, August 29, 2005
 

Good Afternoon,

I have written the following script, but it's not meeting the requirements I have been given, but I am confused as to how to proceed:

I want to alter the script so that the secret number is between 1 and 100, and after each incorrect guess a hint is given about whether to guess higher or lower.

function game()
{
var secretnum = Math.floor(Math.random() * 100) + 1;
var guess = prompt("Enter a guess from 1 to 100", "");
var numguesses = 1;
while (guess != secretnum)
{
numguesses++;
guess = prompt("Wrong, try again with guess number " + numguesses, "");
}
alert("You guessed the number in " + numguesses + " guesses");
}









CodeToad Experts

Can't find the answer?
Our Site experts are answering questions for free in the CodeToad forums








Recent Forum Threads
•  Why Use Method?
•  Re: Help with filesystem object & displaying in a table
•  Re: Genetic Algorithm Help
•  Re: How to make an investment calculator
•  Re: line breaks in GUI
•  Re: Graph in Gui...
•  Graph in Gui...
•  Re: Counting zero values in a string
•  Re: Help!


Recent Articles
Multiple submit buttons with form validation
Understanding Hibernate ORM for Java/J2EE
HTTP screen-scraping and caching
a javascript calculator
A simple way to JTable
Java Native Interface (JNI)
Parsing Dynamic Layouts
MagicGrid
Caching With ASP.Net
Creating CSS Buttons


Site Survey
Help us serve you better. Take a five minute survey. Click here!

© Copyright codetoad.com 2001-2005