Asher
11-04-2006, 04:25 PM
Hello fellow coding masters and newcomers. I need this code to be dulled down a bit from being a professional code to being more of a school based code. Could anyone please help? I need it done asap.
thank you, Ash.
function next () {
if ( question[id] == "end" ) {
// if the next question is 'end' then we have no more questions
// Display the answers and how the user went,
// Define our var's and give them some default values
var x=1 ;
var text = "";
var total = id-1;
var correct = 0;
var money = 100;
// Text will hold the output we will see
text = "<h1>Answers:</h1>";
// Loop through all the questions, from 1 to the current id
for ( x = 1 ; x < id ; x++ )
{
// Append the question, answer and to our output
text = text + '<h3>Question' + x + "</h3>" ;
text = text + "Q :: " + question[x] + "<br>"
text = text + "A :: " + answer[x] + "<br>"
//text = text + "Guess :: " + guess[x] + "<br>";
if ( answer[x].toLowerCase() == guess[x].toLowerCase() ) {
// if the answer is the same as the guess then they are correct
// Append 'correct' to the output
text = text + "<div style=\"color:green\"><b>Correct</b></div>";
// Increment out Correct-o-meter
correct = correct + 1
// Double our money! Woot!
money = money * 2
}else{
// if the answer is differant... well they suck
// Append 'incorrect' to output
text = text + "<div style=\"color:red\"><b>Incorrect</b></div>";
}
// Append some extra spaces
text = text + "<br>"
}
// Append the total score to the output
text = text + "Your Score: " + correct + "/" + total
// Append the money won to the output
text = text + "<br>Your Won: $" + money
// alert the player how much they have won
alert("<br>Your Won: $" + money)
// Sets the main div to contain the output
document.getElementById('main').innerHTML = text
thank you, Ash.
function next () {
if ( question[id] == "end" ) {
// if the next question is 'end' then we have no more questions
// Display the answers and how the user went,
// Define our var's and give them some default values
var x=1 ;
var text = "";
var total = id-1;
var correct = 0;
var money = 100;
// Text will hold the output we will see
text = "<h1>Answers:</h1>";
// Loop through all the questions, from 1 to the current id
for ( x = 1 ; x < id ; x++ )
{
// Append the question, answer and to our output
text = text + '<h3>Question' + x + "</h3>" ;
text = text + "Q :: " + question[x] + "<br>"
text = text + "A :: " + answer[x] + "<br>"
//text = text + "Guess :: " + guess[x] + "<br>";
if ( answer[x].toLowerCase() == guess[x].toLowerCase() ) {
// if the answer is the same as the guess then they are correct
// Append 'correct' to the output
text = text + "<div style=\"color:green\"><b>Correct</b></div>";
// Increment out Correct-o-meter
correct = correct + 1
// Double our money! Woot!
money = money * 2
}else{
// if the answer is differant... well they suck
// Append 'incorrect' to output
text = text + "<div style=\"color:red\"><b>Incorrect</b></div>";
}
// Append some extra spaces
text = text + "<br>"
}
// Append the total score to the output
text = text + "Your Score: " + correct + "/" + total
// Append the money won to the output
text = text + "<br>Your Won: $" + money
// alert the player how much they have won
alert("<br>Your Won: $" + money)
// Sets the main div to contain the output
document.getElementById('main').innerHTML = text