Posted by: Sourav | February 3, 2012

A simple quiz program using Javascript


<script>

quesans=[[‘How many paisa in one rupee?’,100],[‘How many megabyte in one gigabyte?’,1000],[‘How many gigabytes in one terabyte?’,1000]];
var score=0;
for(var i=0;i<quesans.length;i++)
{
 
 var j=1;var k=0;
 var ques=(quesans[i]);
 var question=ques[k];
 
 var ans=(ques[j]);
 var answer=prompt(question,” “);
 if(answer==ans)
 {
  score=score+1;
  var b=i+1;
  alert(“correct answer”);
  alert(“Your score is “+ score +”out of “+b);
  
  
  
 }
 
 else

    {
  alert(“wrong answer”);
  
  var b=i+1;
  alert(“Your score is “+ score +” out of “+b);
  
  
 }
}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Categories

%d bloggers like this: