I have created a function to take someone through a short series of questions, but when I try to push the button on the webpage it does nothing. I have gone through it a couple of times and have been unable to see where I have gone wrong. Here is the code for the function:
function womenTrivia();
{
var count = 0;
Meg();
function Meg();
{
var questionMeg = window.prompt("Who does Meg marry?");
var sentMeg = 'John Brooke';
window.prompt("Who does Meg marry?");
if(questionMeg != sentMeg)
{
questionMeg = window.prompt("Who does Meg marry?");
}
else
{
count = count + 1;
window.alert("You are Correct!");
}
if(count == 1)
{
Jo();
}
}
function Jo();
{
var questionJo = window.prompt("Where does Jo travel to pursue a literary career?");
var sentJo = 'New York City';
window.prompt("What does Jo travel to pursue a literary career?");
if(questionJo != sentJo)
{
questionJo = window.prompt("Where does Jo travel to pursue a literay career?");
}
else
{
count = count + 1;
window.alert("You are Correct!");
}
if(count == 2)
{
Beth();
}
}
function Beth();
{
var questionBeth = window.prompt("What causes Beth's health to deteriorate?");
var sentBeth = 'Scarlet Fever';
window.prompt("What causes Beth's health to deteriorate?");
if(questionBeth != sentBeth)
{
questionBeth = window.prompt("What causes Beth's health to deteriorate?");
}
else
{
count = count + 1;
window.alert("You are Correct!");
}
if(count == 3)
{
Amy();
}
}
function Amy();
{
var questionAmy = window.prompt("Is Amy the youngest sister, True or False?");
var sentAmy = 'True';
window.prompt("Is Amy the youngest sister, True or False?");
if(questionAmy != sentAmy)
{
questionAmy = window.prompt("Is Amy the youngest sister, True or False?");
}
else
{
count = count + 1;
window.alert("You are Correct!");
}
if(count == 4);
{
window.alert("Congratulations, you have finished the Trivia!");
}
}
}
And this is the code for the button to be pressed on the screen:
<p><input type="button" onclick="womenTrivia();" value="Little Women Trivia" class="auto-style4" style="width: 172px; height: 25px;"></p>
function womenTrivia();
{
var count = 0;
Meg();
function Meg();
{
var questionMeg = window.prompt("Who does Meg marry?");
var sentMeg = 'John Brooke';
window.prompt("Who does Meg marry?");
if(questionMeg != sentMeg)
{
questionMeg = window.prompt("Who does Meg marry?");
}
else
{
count = count + 1;
window.alert("You are Correct!");
}
if(count == 1)
{
Jo();
}
}
function Jo();
{
var questionJo = window.prompt("Where does Jo travel to pursue a literary career?");
var sentJo = 'New York City';
window.prompt("What does Jo travel to pursue a literary career?");
if(questionJo != sentJo)
{
questionJo = window.prompt("Where does Jo travel to pursue a literay career?");
}
else
{
count = count + 1;
window.alert("You are Correct!");
}
if(count == 2)
{
Beth();
}
}
function Beth();
{
var questionBeth = window.prompt("What causes Beth's health to deteriorate?");
var sentBeth = 'Scarlet Fever';
window.prompt("What causes Beth's health to deteriorate?");
if(questionBeth != sentBeth)
{
questionBeth = window.prompt("What causes Beth's health to deteriorate?");
}
else
{
count = count + 1;
window.alert("You are Correct!");
}
if(count == 3)
{
Amy();
}
}
function Amy();
{
var questionAmy = window.prompt("Is Amy the youngest sister, True or False?");
var sentAmy = 'True';
window.prompt("Is Amy the youngest sister, True or False?");
if(questionAmy != sentAmy)
{
questionAmy = window.prompt("Is Amy the youngest sister, True or False?");
}
else
{
count = count + 1;
window.alert("You are Correct!");
}
if(count == 4);
{
window.alert("Congratulations, you have finished the Trivia!");
}
}
}
And this is the code for the button to be pressed on the screen:
<p><input type="button" onclick="womenTrivia();" value="Little Women Trivia" class="auto-style4" style="width: 172px; height: 25px;"></p>