SlideShare una empresa de Scribd logo
1 de 10
Descargar para leer sin conexión
JAVASCRIPT Quiz                               by Kishan Phadte




<HTML>

<HEAD>

<TITLE>Quiz Program</TITLE>

<SCRIPT LANGUAGE="JavaScript">

//Question object

function Question() {

this.question=Question.arguments[0]

var n=Question.arguments.length

this.answers = new Array(n-2)

for(var i=1; i<n-1; ++i)

    this.answers[i-1]=Question.arguments[i]

this.correctAnswer=Question.arguments[n-1]

}

function readCookie() {
currentQuestion=0

numberOfQuestions=0

correctAnswers=0

score="None"

cookie=document.cookie

currentQuestion=getNumberValue(cookie,"currentQuestion")

numberOfQuestions=getNumberValue(cookie,"numberOfQuestions")

correctAnswers=getNumberValue(cookie,"correctAnswers")

if(numberOfQuestions>0)

    score=Math.round(correctAnswers*100/numberOfQuestions)

}

function getNumberValue(s,n) {

s=removeBlanks(s)

var pairs=s.split(";")

for(var i=0;i<pairs.length;++i) {

    var pairSplit=pairs[i].split("=")

    if(pairSplit[0]==n) {

    if(pairSplit.length>1) return parseInt(pairSplit[1])

    else return 0

    }

}

return 0

}

function removeBlanks(s) {

var temp=""
for(var i=0;i<s.length;++i) {

    var c=s.charAt(i)

    if(c!=" ") temp += c

}

return temp

}

function askNextQuestion() {

document.writeln("<H4 ALIGN='LEFT'>"

    +qa[currentQuestion].question+"</H4>")

displayAnswers()

}

function displayAnswers() {

document.writeln('<FORM NAME="answerForm">')

for(var ii=0;ii<qa[currentQuestion].answers.length;++ii) {

    document.writeln('<H4 ALIGN="LEFT">')

    document.writeln('<INPUT TYPE="RADIO" NAME="answer"> ')

    document.writeln(qa[currentQuestion].answers[ii])

    if(ii+1==qa[currentQuestion].answers.length) {

    document.writeln('<BR><BR><INPUT TYPE="BUTTON"')

    document.writeln('NAME="continue" VALUE="Continue" ')

    document.writeln(' onClick="checkAnswers()">')

    }

    document.writeln('</H4>')

}

document.writeln('</FORM>')
}

function checkAnswers() {

var numAnswers=qa[currentQuestion].answers.length

var correctAnswer=qa[currentQuestion].correctAnswer

for(var jj=0;jj<numAnswers;++jj) {

    if(document.answerForm.elements[jj].checked) {

    if(jj==correctAnswer){

        correct()

        break

    }else{

        incorrect()

        break

    }

    }

    if(jj==numAnswers){

    incorrect()

    break

    }

}

}

function correct() {

++currentQuestion

++numberOfQuestions

++correctAnswers

updateCookie()
location.reload(true)

}

function incorrect() {

++numberOfQuestions

updateCookie()

alert("Incorrect!")

location.reload(true)

}

function updateCookie() {

document.cookie="currentQuestion="+currentQuestion

document.cookie="numberOfQuestions="+numberOfQuestions

document.cookie="correctAnswers="+correctAnswers

}

function endQuiz() {

document.cookie="currentQuestion=0"

document.cookie="numberOfQuestions=0"

document.cookie="correctAnswers=0"

document.writeln('<FORM NAME="finishedForm">')

document.write("<H4 ALIGN='CENTER'>")

document.write("Congratulations! You have finished this quiz.")

document.write('<BR><BR>')

document.write("<img src='so.jpg' width=200 height=200 align='center'")

document.write('<BR><BR><INPUT TYPE="BUTTON" ')

document.writeln('NAME="restart" VALUE="Restart" ')

document.writeln(' onClick="restartQuiz()">')
document.writeln("</H4>")

document.writeln('</FORM>')

}

function restartQuiz()

{

location.reload(true);

}

</SCRIPT>



<SCRIPT LANGUAGE="JavaScript">

pageHeading="Corrupt Governance Quiz"

//Questions

var qa = new Array()

qa[0] = new Question("1) Who is the lead actor in the Lokpal Bill ?",

"Anna Hazare",

"John Abraham",

"Hrithik Roshan",

"Akshay Kumar",

0)

qa[1] = new Question("2) Who out of these set INDIA'S WINGS ON FIRE ?",

"Dragon",

"Gabbar Singh",

"Sonia Gandhi",

"Fireman",

2)
qa[2] = new Question("3) After how many days did ANNA Hazare break his hunger strike?",

"365 days",

"13 days",

"12 years",

"1 day",

1)

qa[3] = new Question("4) Who said that he is ANNAs <i>HANUMAN</i>?",

"KApil Sibbal",

"Arvind Kejriwaal",

"Sanjay Khan",

"Sanjay Dutt",

1)

qa[4] = new Question("5) Who is Father of our nation?",

"Laloo Prasad Yadav",

"Amar Singh",

"Sardar Manmohan Singh",

"M.K. Gandhi",

3)

qa[5] = new Question("6) Who believes in <I>CORRUPTION</I>?",

"Eminem",

"Bob Marley",

"Sonia Chor Gandhi",

"AKON",

2)

qa[6] = new Question("7) Anna Hazare is ",
"Labour (Gawandi)",

"Ex- Armyman",

"Gangster",

"Corrupt Minister",

1)

qa[7] = new Question("8) Who is SMS?",

"Salvatore Dali",

"Sardar Manmohan Singh",

"Rahul R. Gandhi",

"Narendra Modi",

1)

qa[8] = new Question("9) Who is Kiran Bedi?",

"IAS officer",

"Bus conductor",

"Animal activist",

"Scientist"

,0)

qa[9] = new Question("10) Who is <b>Arvind Kejriwal</b>?",

"Engineer from IIT Kharagpur",

"Surgeon",

"Astronomer",

"Fasting Specialist",

0)



</SCRIPT>
</HEAD>

<BODY>

<SCRIPT LANGUAGE="JavaScript"><!--

readCookie()

document.writeln("<H1 ALIGN='LEFT'>"+"<img src=corruption.jpg width=980 height=120/>"
+"<br>" +pageHeading+"</H1>"+"<hr>")

document.writeln("<P ALIGN='RIGHT'><B>Questions: "

+numberOfQuestions+"<BR>")

document.writeln("Correct Answers: "+correctAnswers+"<BR>")

document.writeln("Score: "+score+"</B>")



document.writeln("<img ALIGN='RIGHT' src='co.jpg' width=150 height=300/>")

if(currentQuestion >= qa.length) endQuiz()

else askNextQuestion()

// --></SCRIPT>

</BODY>

</HTML>
Result :

Más contenido relacionado

La actualidad más candente

The Testing Games: Mocking, yay!
The Testing Games: Mocking, yay!The Testing Games: Mocking, yay!
The Testing Games: Mocking, yay!Donny Wals
 
The Ring programming language version 1.5.3 book - Part 44 of 184
The Ring programming language version 1.5.3 book - Part 44 of 184The Ring programming language version 1.5.3 book - Part 44 of 184
The Ring programming language version 1.5.3 book - Part 44 of 184Mahmoud Samir Fayed
 
Lowering in C#: What really happens with your code?, from NDC Oslo 2019
Lowering in C#: What really happens with your code?, from NDC Oslo 2019Lowering in C#: What really happens with your code?, from NDC Oslo 2019
Lowering in C#: What really happens with your code?, from NDC Oslo 2019David Wengier
 
The Ring programming language version 1.3 book - Part 34 of 88
The Ring programming language version 1.3 book - Part 34 of 88The Ring programming language version 1.3 book - Part 34 of 88
The Ring programming language version 1.3 book - Part 34 of 88Mahmoud Samir Fayed
 
The secret unit testing tools no one has ever told you about
The secret unit testing tools no one has ever told you aboutThe secret unit testing tools no one has ever told you about
The secret unit testing tools no one has ever told you aboutDror Helper
 
The Ring programming language version 1.10 book - Part 54 of 212
The Ring programming language version 1.10 book - Part 54 of 212The Ring programming language version 1.10 book - Part 54 of 212
The Ring programming language version 1.10 book - Part 54 of 212Mahmoud Samir Fayed
 
The Ring programming language version 1.5.1 book - Part 51 of 180
The Ring programming language version 1.5.1 book - Part 51 of 180The Ring programming language version 1.5.1 book - Part 51 of 180
The Ring programming language version 1.5.1 book - Part 51 of 180Mahmoud Samir Fayed
 
Михаил Матросов, Повседневный С++: boost и STL
Михаил Матросов, Повседневный С++: boost и STLМихаил Матросов, Повседневный С++: boost и STL
Михаил Матросов, Повседневный С++: boost и STLSergey Platonov
 
Indexing & query optimization
Indexing & query optimizationIndexing & query optimization
Indexing & query optimizationJared Rosoff
 
The Ring programming language version 1.2 book - Part 32 of 84
The Ring programming language version 1.2 book - Part 32 of 84The Ring programming language version 1.2 book - Part 32 of 84
The Ring programming language version 1.2 book - Part 32 of 84Mahmoud Samir Fayed
 
The Ring programming language version 1.3 book - Part 42 of 88
The Ring programming language version 1.3 book - Part 42 of 88The Ring programming language version 1.3 book - Part 42 of 88
The Ring programming language version 1.3 book - Part 42 of 88Mahmoud Samir Fayed
 
JSON and Swift, Still A Better Love Story Than Twilight
JSON and Swift, Still A Better Love Story Than TwilightJSON and Swift, Still A Better Love Story Than Twilight
JSON and Swift, Still A Better Love Story Than TwilightDonny Wals
 
The Ring programming language version 1.5.2 book - Part 41 of 181
The Ring programming language version 1.5.2 book - Part 41 of 181The Ring programming language version 1.5.2 book - Part 41 of 181
The Ring programming language version 1.5.2 book - Part 41 of 181Mahmoud Samir Fayed
 
The Ring programming language version 1.9 book - Part 62 of 210
The Ring programming language version 1.9 book - Part 62 of 210The Ring programming language version 1.9 book - Part 62 of 210
The Ring programming language version 1.9 book - Part 62 of 210Mahmoud Samir Fayed
 
Intro to OTP in Elixir
Intro to OTP in ElixirIntro to OTP in Elixir
Intro to OTP in ElixirJesse Anderson
 

La actualidad más candente (20)

The Testing Games: Mocking, yay!
The Testing Games: Mocking, yay!The Testing Games: Mocking, yay!
The Testing Games: Mocking, yay!
 
The Ring programming language version 1.5.3 book - Part 44 of 184
The Ring programming language version 1.5.3 book - Part 44 of 184The Ring programming language version 1.5.3 book - Part 44 of 184
The Ring programming language version 1.5.3 book - Part 44 of 184
 
Lowering in C#: What really happens with your code?, from NDC Oslo 2019
Lowering in C#: What really happens with your code?, from NDC Oslo 2019Lowering in C#: What really happens with your code?, from NDC Oslo 2019
Lowering in C#: What really happens with your code?, from NDC Oslo 2019
 
The Ring programming language version 1.3 book - Part 34 of 88
The Ring programming language version 1.3 book - Part 34 of 88The Ring programming language version 1.3 book - Part 34 of 88
The Ring programming language version 1.3 book - Part 34 of 88
 
The secret unit testing tools no one has ever told you about
The secret unit testing tools no one has ever told you aboutThe secret unit testing tools no one has ever told you about
The secret unit testing tools no one has ever told you about
 
The Ring programming language version 1.10 book - Part 54 of 212
The Ring programming language version 1.10 book - Part 54 of 212The Ring programming language version 1.10 book - Part 54 of 212
The Ring programming language version 1.10 book - Part 54 of 212
 
Django quickstart
Django quickstartDjango quickstart
Django quickstart
 
The Ring programming language version 1.5.1 book - Part 51 of 180
The Ring programming language version 1.5.1 book - Part 51 of 180The Ring programming language version 1.5.1 book - Part 51 of 180
The Ring programming language version 1.5.1 book - Part 51 of 180
 
Vaadin7
Vaadin7Vaadin7
Vaadin7
 
Михаил Матросов, Повседневный С++: boost и STL
Михаил Матросов, Повседневный С++: boost и STLМихаил Матросов, Повседневный С++: boost и STL
Михаил Матросов, Повседневный С++: boost и STL
 
Indexing & query optimization
Indexing & query optimizationIndexing & query optimization
Indexing & query optimization
 
Spock and Geb in Action
Spock and Geb in ActionSpock and Geb in Action
Spock and Geb in Action
 
The Ring programming language version 1.2 book - Part 32 of 84
The Ring programming language version 1.2 book - Part 32 of 84The Ring programming language version 1.2 book - Part 32 of 84
The Ring programming language version 1.2 book - Part 32 of 84
 
The Ring programming language version 1.3 book - Part 42 of 88
The Ring programming language version 1.3 book - Part 42 of 88The Ring programming language version 1.3 book - Part 42 of 88
The Ring programming language version 1.3 book - Part 42 of 88
 
JSON and Swift, Still A Better Love Story Than Twilight
JSON and Swift, Still A Better Love Story Than TwilightJSON and Swift, Still A Better Love Story Than Twilight
JSON and Swift, Still A Better Love Story Than Twilight
 
The Ring programming language version 1.5.2 book - Part 41 of 181
The Ring programming language version 1.5.2 book - Part 41 of 181The Ring programming language version 1.5.2 book - Part 41 of 181
The Ring programming language version 1.5.2 book - Part 41 of 181
 
The Ring programming language version 1.9 book - Part 62 of 210
The Ring programming language version 1.9 book - Part 62 of 210The Ring programming language version 1.9 book - Part 62 of 210
The Ring programming language version 1.9 book - Part 62 of 210
 
Baitap tkw
Baitap tkwBaitap tkw
Baitap tkw
 
MongoDB Oplog入門
MongoDB Oplog入門MongoDB Oplog入門
MongoDB Oplog入門
 
Intro to OTP in Elixir
Intro to OTP in ElixirIntro to OTP in Elixir
Intro to OTP in Elixir
 

Destacado (8)

Javascript quiz. Questions to ask when recruiting developers.
Javascript quiz. Questions to ask when recruiting developers.Javascript quiz. Questions to ask when recruiting developers.
Javascript quiz. Questions to ask when recruiting developers.
 
Javascript Question
Javascript QuestionJavascript Question
Javascript Question
 
Bit%20 ch02
Bit%20 ch02Bit%20 ch02
Bit%20 ch02
 
Ecowhizz Prelims
Ecowhizz PrelimsEcowhizz Prelims
Ecowhizz Prelims
 
XCentricity Quiz 2016 by Apratim Chandra Singh
XCentricity Quiz 2016 by Apratim Chandra SinghXCentricity Quiz 2016 by Apratim Chandra Singh
XCentricity Quiz 2016 by Apratim Chandra Singh
 
Prahelika prelims
Prahelika   prelimsPrahelika   prelims
Prahelika prelims
 
Prahelika finals
Prahelika   finalsPrahelika   finals
Prahelika finals
 
Quiz-Grand Finale
Quiz-Grand FinaleQuiz-Grand Finale
Quiz-Grand Finale
 

Similar a Javascript quiz

RxJava from the trenches
RxJava from the trenchesRxJava from the trenches
RxJava from the trenchesPeter Hendriks
 
How to develop frontend quiz app using vue js
How to develop frontend quiz app using vue jsHow to develop frontend quiz app using vue js
How to develop frontend quiz app using vue jsKaty Slemon
 
The Ring programming language version 1.6 book - Part 70 of 189
The Ring programming language version 1.6 book - Part 70 of 189The Ring programming language version 1.6 book - Part 70 of 189
The Ring programming language version 1.6 book - Part 70 of 189Mahmoud Samir Fayed
 
Webmontag Berlin "coffee script"
Webmontag Berlin "coffee script"Webmontag Berlin "coffee script"
Webmontag Berlin "coffee script"Webmontag Berlin
 
COScheduler In Depth
COScheduler In DepthCOScheduler In Depth
COScheduler In DepthWO Community
 
mobl: Een DSL voor mobiele applicatieontwikkeling
mobl: Een DSL voor mobiele applicatieontwikkelingmobl: Een DSL voor mobiele applicatieontwikkeling
mobl: Een DSL voor mobiele applicatieontwikkelingDevnology
 
The Ring programming language version 1.5.1 book - Part 64 of 180
The Ring programming language version 1.5.1 book - Part 64 of 180The Ring programming language version 1.5.1 book - Part 64 of 180
The Ring programming language version 1.5.1 book - Part 64 of 180Mahmoud Samir Fayed
 
The Ring programming language version 1.7 book - Part 48 of 196
The Ring programming language version 1.7 book - Part 48 of 196The Ring programming language version 1.7 book - Part 48 of 196
The Ring programming language version 1.7 book - Part 48 of 196Mahmoud Samir Fayed
 
javascript function & closure
javascript function & closurejavascript function & closure
javascript function & closureHika Maeng
 
The Ring programming language version 1.7 book - Part 73 of 196
The Ring programming language version 1.7 book - Part 73 of 196The Ring programming language version 1.7 book - Part 73 of 196
The Ring programming language version 1.7 book - Part 73 of 196Mahmoud Samir Fayed
 
The Ring programming language version 1.7 book - Part 72 of 196
The Ring programming language version 1.7 book - Part 72 of 196The Ring programming language version 1.7 book - Part 72 of 196
The Ring programming language version 1.7 book - Part 72 of 196Mahmoud Samir Fayed
 
The Ring programming language version 1.8 book - Part 75 of 202
The Ring programming language version 1.8 book - Part 75 of 202The Ring programming language version 1.8 book - Part 75 of 202
The Ring programming language version 1.8 book - Part 75 of 202Mahmoud Samir Fayed
 
The Ring programming language version 1.5.4 book - Part 44 of 185
The Ring programming language version 1.5.4 book - Part 44 of 185The Ring programming language version 1.5.4 book - Part 44 of 185
The Ring programming language version 1.5.4 book - Part 44 of 185Mahmoud Samir Fayed
 
Callbacks, Promises, and Coroutines (oh my!): Asynchronous Programming Patter...
Callbacks, Promises, and Coroutines (oh my!): Asynchronous Programming Patter...Callbacks, Promises, and Coroutines (oh my!): Asynchronous Programming Patter...
Callbacks, Promises, and Coroutines (oh my!): Asynchronous Programming Patter...Domenic Denicola
 
having trouble with my code I'm using VScode to code a javascript code.docx
having trouble with my code I'm using VScode to code a javascript code.docxhaving trouble with my code I'm using VScode to code a javascript code.docx
having trouble with my code I'm using VScode to code a javascript code.docxIsaac9LjWelchq
 
Damn Fine CoffeeScript
Damn Fine CoffeeScriptDamn Fine CoffeeScript
Damn Fine CoffeeScriptniklal
 
Asynchronous web apps with the Play Framework 2.0
Asynchronous web apps with the Play Framework 2.0Asynchronous web apps with the Play Framework 2.0
Asynchronous web apps with the Play Framework 2.0Oscar Renalias
 
Understanding JavaScript Testing
Understanding JavaScript TestingUnderstanding JavaScript Testing
Understanding JavaScript Testingjeresig
 
Testing, Performance Analysis, and jQuery 1.4
Testing, Performance Analysis, and jQuery 1.4Testing, Performance Analysis, and jQuery 1.4
Testing, Performance Analysis, and jQuery 1.4jeresig
 

Similar a Javascript quiz (20)

RxJava from the trenches
RxJava from the trenchesRxJava from the trenches
RxJava from the trenches
 
How to develop frontend quiz app using vue js
How to develop frontend quiz app using vue jsHow to develop frontend quiz app using vue js
How to develop frontend quiz app using vue js
 
The Ring programming language version 1.6 book - Part 70 of 189
The Ring programming language version 1.6 book - Part 70 of 189The Ring programming language version 1.6 book - Part 70 of 189
The Ring programming language version 1.6 book - Part 70 of 189
 
Webmontag Berlin "coffee script"
Webmontag Berlin "coffee script"Webmontag Berlin "coffee script"
Webmontag Berlin "coffee script"
 
COScheduler In Depth
COScheduler In DepthCOScheduler In Depth
COScheduler In Depth
 
mobl: Een DSL voor mobiele applicatieontwikkeling
mobl: Een DSL voor mobiele applicatieontwikkelingmobl: Een DSL voor mobiele applicatieontwikkeling
mobl: Een DSL voor mobiele applicatieontwikkeling
 
The Ring programming language version 1.5.1 book - Part 64 of 180
The Ring programming language version 1.5.1 book - Part 64 of 180The Ring programming language version 1.5.1 book - Part 64 of 180
The Ring programming language version 1.5.1 book - Part 64 of 180
 
The Ring programming language version 1.7 book - Part 48 of 196
The Ring programming language version 1.7 book - Part 48 of 196The Ring programming language version 1.7 book - Part 48 of 196
The Ring programming language version 1.7 book - Part 48 of 196
 
javascript function & closure
javascript function & closurejavascript function & closure
javascript function & closure
 
The Ring programming language version 1.7 book - Part 73 of 196
The Ring programming language version 1.7 book - Part 73 of 196The Ring programming language version 1.7 book - Part 73 of 196
The Ring programming language version 1.7 book - Part 73 of 196
 
The Ring programming language version 1.7 book - Part 72 of 196
The Ring programming language version 1.7 book - Part 72 of 196The Ring programming language version 1.7 book - Part 72 of 196
The Ring programming language version 1.7 book - Part 72 of 196
 
The Ring programming language version 1.8 book - Part 75 of 202
The Ring programming language version 1.8 book - Part 75 of 202The Ring programming language version 1.8 book - Part 75 of 202
The Ring programming language version 1.8 book - Part 75 of 202
 
The Ring programming language version 1.5.4 book - Part 44 of 185
The Ring programming language version 1.5.4 book - Part 44 of 185The Ring programming language version 1.5.4 book - Part 44 of 185
The Ring programming language version 1.5.4 book - Part 44 of 185
 
Callbacks, Promises, and Coroutines (oh my!): Asynchronous Programming Patter...
Callbacks, Promises, and Coroutines (oh my!): Asynchronous Programming Patter...Callbacks, Promises, and Coroutines (oh my!): Asynchronous Programming Patter...
Callbacks, Promises, and Coroutines (oh my!): Asynchronous Programming Patter...
 
CoffeeScript
CoffeeScriptCoffeeScript
CoffeeScript
 
having trouble with my code I'm using VScode to code a javascript code.docx
having trouble with my code I'm using VScode to code a javascript code.docxhaving trouble with my code I'm using VScode to code a javascript code.docx
having trouble with my code I'm using VScode to code a javascript code.docx
 
Damn Fine CoffeeScript
Damn Fine CoffeeScriptDamn Fine CoffeeScript
Damn Fine CoffeeScript
 
Asynchronous web apps with the Play Framework 2.0
Asynchronous web apps with the Play Framework 2.0Asynchronous web apps with the Play Framework 2.0
Asynchronous web apps with the Play Framework 2.0
 
Understanding JavaScript Testing
Understanding JavaScript TestingUnderstanding JavaScript Testing
Understanding JavaScript Testing
 
Testing, Performance Analysis, and jQuery 1.4
Testing, Performance Analysis, and jQuery 1.4Testing, Performance Analysis, and jQuery 1.4
Testing, Performance Analysis, and jQuery 1.4
 

Más de DM's College, Assagao Goa

Más de DM's College, Assagao Goa (9)

Chap12 project procurement management
Chap12 project procurement managementChap12 project procurement management
Chap12 project procurement management
 
Chap09 project human resource management
Chap09 project human resource managementChap09 project human resource management
Chap09 project human resource management
 
Chap08 project quality management
Chap08 project quality  managementChap08 project quality  management
Chap08 project quality management
 
Chap06 project time management
Chap06 project time managementChap06 project time management
Chap06 project time management
 
Chap04 project integration management
Chap04 project integration managementChap04 project integration management
Chap04 project integration management
 
Chap01 introduction to project management
Chap01 introduction to project managementChap01 introduction to project management
Chap01 introduction to project management
 
Personal website
Personal websitePersonal website
Personal website
 
Kishan Phadte's HTML Cross word
Kishan Phadte's HTML Cross wordKishan Phadte's HTML Cross word
Kishan Phadte's HTML Cross word
 
Android a glimpse by kishan phadte(BCA, Third Year undergraduate at DM's Col...
Android a glimpse by kishan phadte(BCA, Third Year undergraduate at  DM's Col...Android a glimpse by kishan phadte(BCA, Third Year undergraduate at  DM's Col...
Android a glimpse by kishan phadte(BCA, Third Year undergraduate at DM's Col...
 

Último

08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 

Último (20)

08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 

Javascript quiz

  • 1. JAVASCRIPT Quiz by Kishan Phadte <HTML> <HEAD> <TITLE>Quiz Program</TITLE> <SCRIPT LANGUAGE="JavaScript"> //Question object function Question() { this.question=Question.arguments[0] var n=Question.arguments.length this.answers = new Array(n-2) for(var i=1; i<n-1; ++i) this.answers[i-1]=Question.arguments[i] this.correctAnswer=Question.arguments[n-1] } function readCookie() {
  • 2. currentQuestion=0 numberOfQuestions=0 correctAnswers=0 score="None" cookie=document.cookie currentQuestion=getNumberValue(cookie,"currentQuestion") numberOfQuestions=getNumberValue(cookie,"numberOfQuestions") correctAnswers=getNumberValue(cookie,"correctAnswers") if(numberOfQuestions>0) score=Math.round(correctAnswers*100/numberOfQuestions) } function getNumberValue(s,n) { s=removeBlanks(s) var pairs=s.split(";") for(var i=0;i<pairs.length;++i) { var pairSplit=pairs[i].split("=") if(pairSplit[0]==n) { if(pairSplit.length>1) return parseInt(pairSplit[1]) else return 0 } } return 0 } function removeBlanks(s) { var temp=""
  • 3. for(var i=0;i<s.length;++i) { var c=s.charAt(i) if(c!=" ") temp += c } return temp } function askNextQuestion() { document.writeln("<H4 ALIGN='LEFT'>" +qa[currentQuestion].question+"</H4>") displayAnswers() } function displayAnswers() { document.writeln('<FORM NAME="answerForm">') for(var ii=0;ii<qa[currentQuestion].answers.length;++ii) { document.writeln('<H4 ALIGN="LEFT">') document.writeln('<INPUT TYPE="RADIO" NAME="answer"> ') document.writeln(qa[currentQuestion].answers[ii]) if(ii+1==qa[currentQuestion].answers.length) { document.writeln('<BR><BR><INPUT TYPE="BUTTON"') document.writeln('NAME="continue" VALUE="Continue" ') document.writeln(' onClick="checkAnswers()">') } document.writeln('</H4>') } document.writeln('</FORM>')
  • 4. } function checkAnswers() { var numAnswers=qa[currentQuestion].answers.length var correctAnswer=qa[currentQuestion].correctAnswer for(var jj=0;jj<numAnswers;++jj) { if(document.answerForm.elements[jj].checked) { if(jj==correctAnswer){ correct() break }else{ incorrect() break } } if(jj==numAnswers){ incorrect() break } } } function correct() { ++currentQuestion ++numberOfQuestions ++correctAnswers updateCookie()
  • 5. location.reload(true) } function incorrect() { ++numberOfQuestions updateCookie() alert("Incorrect!") location.reload(true) } function updateCookie() { document.cookie="currentQuestion="+currentQuestion document.cookie="numberOfQuestions="+numberOfQuestions document.cookie="correctAnswers="+correctAnswers } function endQuiz() { document.cookie="currentQuestion=0" document.cookie="numberOfQuestions=0" document.cookie="correctAnswers=0" document.writeln('<FORM NAME="finishedForm">') document.write("<H4 ALIGN='CENTER'>") document.write("Congratulations! You have finished this quiz.") document.write('<BR><BR>') document.write("<img src='so.jpg' width=200 height=200 align='center'") document.write('<BR><BR><INPUT TYPE="BUTTON" ') document.writeln('NAME="restart" VALUE="Restart" ') document.writeln(' onClick="restartQuiz()">')
  • 6. document.writeln("</H4>") document.writeln('</FORM>') } function restartQuiz() { location.reload(true); } </SCRIPT> <SCRIPT LANGUAGE="JavaScript"> pageHeading="Corrupt Governance Quiz" //Questions var qa = new Array() qa[0] = new Question("1) Who is the lead actor in the Lokpal Bill ?", "Anna Hazare", "John Abraham", "Hrithik Roshan", "Akshay Kumar", 0) qa[1] = new Question("2) Who out of these set INDIA'S WINGS ON FIRE ?", "Dragon", "Gabbar Singh", "Sonia Gandhi", "Fireman", 2)
  • 7. qa[2] = new Question("3) After how many days did ANNA Hazare break his hunger strike?", "365 days", "13 days", "12 years", "1 day", 1) qa[3] = new Question("4) Who said that he is ANNAs <i>HANUMAN</i>?", "KApil Sibbal", "Arvind Kejriwaal", "Sanjay Khan", "Sanjay Dutt", 1) qa[4] = new Question("5) Who is Father of our nation?", "Laloo Prasad Yadav", "Amar Singh", "Sardar Manmohan Singh", "M.K. Gandhi", 3) qa[5] = new Question("6) Who believes in <I>CORRUPTION</I>?", "Eminem", "Bob Marley", "Sonia Chor Gandhi", "AKON", 2) qa[6] = new Question("7) Anna Hazare is ",
  • 8. "Labour (Gawandi)", "Ex- Armyman", "Gangster", "Corrupt Minister", 1) qa[7] = new Question("8) Who is SMS?", "Salvatore Dali", "Sardar Manmohan Singh", "Rahul R. Gandhi", "Narendra Modi", 1) qa[8] = new Question("9) Who is Kiran Bedi?", "IAS officer", "Bus conductor", "Animal activist", "Scientist" ,0) qa[9] = new Question("10) Who is <b>Arvind Kejriwal</b>?", "Engineer from IIT Kharagpur", "Surgeon", "Astronomer", "Fasting Specialist", 0) </SCRIPT>
  • 9. </HEAD> <BODY> <SCRIPT LANGUAGE="JavaScript"><!-- readCookie() document.writeln("<H1 ALIGN='LEFT'>"+"<img src=corruption.jpg width=980 height=120/>" +"<br>" +pageHeading+"</H1>"+"<hr>") document.writeln("<P ALIGN='RIGHT'><B>Questions: " +numberOfQuestions+"<BR>") document.writeln("Correct Answers: "+correctAnswers+"<BR>") document.writeln("Score: "+score+"</B>") document.writeln("<img ALIGN='RIGHT' src='co.jpg' width=150 height=300/>") if(currentQuestion >= qa.length) endQuiz() else askNextQuestion() // --></SCRIPT> </BODY> </HTML>