/    Sign up×
Community /Pin to ProfileBookmark

help needed plz!!!

[B][COLOR=”Red”]hi i cant fix the follwojng. ive built it but its not working now,. did do but then i tried to input code so a box asks to contnue and you press yes to play again and no to finish. can some help me finish it?[/COLOR][/B]

code :

<HTML>
<HEAD>
<TITLE>Web Development</TITLE>
<SCRIPT TYPE=”text/javascript” LANGUAGE=”JavaScript”>
<!– Hide Script from old browsers

var game_number, user_number, guess;
var play_again=””;

do
{
// Generate game number
game_number=parseInt(Math.floor(Math.random()*101));

document.write(“New game: Game number generated.<BR>”);

// Get the users first guess
user_number = window.prompt(“Enter your guess (1 through 100), (0 quits the game):”, “”);
guess = parseInt(user_number);

while ((guess != game_number) && (guess != 0))
{
if (guess > game_number)
document.write(“Guess = ” + guess + “. You need to guess lower<BR>”);
else
document.write(“Guess = ” + guess + “. You need to guess higher<BR>”);

// Get the users next guess
user_number = window.prompt(“Enter your guess (1 through 100), (0 quits the game):”, “”);
guess = parseInt(user_number);
}

if (guess == game_number)
{
// User has guessed correctly
window.alert(“You guess correctly!!! ” + guess + ” is the number, well done.”);
play_again = window.prompt(“Do you wish to play again (Y/N):”, “Y”); = window.prompt(“Do you wish to play again (Y/N):”, “Y”);
}
if (play_again==”Y” || play_again==”Y”)
{

document.location=document.location;

} while ((guess != 0) && (play_again == “N”) && (play_again == “n”));

// End Script Hiding –>
</SCRIPT>
</HEAD>
<BODY>
</BODY>
</HTML>

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@cgishackFeb 23.2008 — you have a lot of syntax errors.

I suggest using FireBug to help you through them all

www.getfirebug.com

Drew
Copy linkTweet thisAlerts:
@munnsie1authorFeb 23.2008 — cn any1 else help and sow me ot code is wrong?
Copy linkTweet thisAlerts:
@cgishackFeb 23.2008 — Your issues are:

Why do you have 2 prompts ? (remove red)
<i>
</i>play_again = window.prompt("Do you wish to play again (Y/N):", "Y"); [B][COLOR="Red"]= window.prompt("Do you wish to play again (Y/N):", "Y");[/COLOR][/B]


You are missing a } at the end of your do loop (see red)

<i>
</i>.....
....
document.location=document.location;

} while ((guess != 0) &amp;&amp; (play_again == "N") &amp;&amp; (play_again == "n"));

[COLOR="Red"]}[/COLOR]



Firebug told me these within 5 seconds of running your application.

I still suggest installing Firebug to help you debug further.
×

Success!

Help @munnsie1 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...