...

View Full Version : IF/else help



Aceflamer
10-05-2008, 06:27 PM
<script type="text/javascript">
var y=prompt("What is your name?")
alert(y + "?!?!?! Now that's a stupid name, who would ever name there kid that?")
alert("Just kidding " + y + " is a nice name.")
var noa=prompt("How many of these do you think there are?",92)
if (noa > 1000) {
var x=confirm(noa + "?!?! Am I that rude?")
if (!x) {
alert("nah I'm not, it's 1000.")
}
else {
alert("Your Correct I'm not that rude, it's 1000.")
}
else if (noa < 1000) {
alert("Are you sure?")
alert("Well your wrong, it's 1000.") /* 6 alerts */
}
else if (noa == 1000) {
alert("Holy ****.")
alert("You Guessed right.")
}
}
alert("So your going to be sitting here for a while")
</script>
can someone please help me? i know its simple... I'm missing something somewhere... nothing works...

Arty Effem
10-05-2008, 07:45 PM
The (FireFox) error console will help you find the syntax error(s). As for the grammatical errors, I'd say you're beyond help.

Aceflamer
10-05-2008, 07:57 PM
The (FireFox) error console will help you find the syntax error(s). As for the grammatical errors, I'd say you're beyond help.

grammatical errors? lol

syntax errors is just the "else" statement, and i can't seem fix it...

Arty Effem
10-05-2008, 09:41 PM
grammatical errors? lol

syntax errors is just the "else" statement, and i can't seem fix it...
Here's the same code laid-out with the brace pairs aligned. You can see there are two consecutive else clauses.


<script type="text/javascript">
var y=prompt("What is your name?")
alert(y + "?!?!?! Now that's a stupid name, who would ever name there kid that?")
alert("Just kidding " + y + " is a nice name.")
var noa=prompt("How many of these do you think there are?",92)
if (noa > 1000)
{
var x=confirm(noa + "?!?! Am I that rude?")
if (!x)
{
alert("nah I'm not, it's 1000.")
}
else
{
alert("Your Correct I'm not that rude, it's 1000.")
}

else
if (noa < 1000)
{
alert("Are you sure?")
alert("Well your wrong, it's 1000.") /* 6 alerts */
}
else if (noa == 1000)
{
alert("Holy ****.")
alert("You Guessed right.")
}
}

alert("So your going to be sitting here for a while")

</script>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum