quiz javascript example with array
var questions = [
["What is the capital of England?", "LONDON", "You know, where the queen lives"],
["What is the capital of France?", "PARIS", "Remember the eiffel tower?"],
["What is the capital of Canada?", "OTTAWA", "Lot of mooses there"]
];
var correctAnswers = 0;
for (var i = 0; i < questions.length; i++) {
var answer = prompt(questions[i][0]);
if (answer.toUpperCase() == questions[i][1]) {
alert("Correct! " + questions[i][2]);
correctAnswers++;
}
else {
alert("incorrect, the correct answer was " + questions[i][1]);
}
}
Also in JavaScript:
- js json escape
- get browser timezone javascript
- How to format a JavaScript date
- how to append rows in table using jquery each function
- javascript es6 dom manipulation
- autocomplete data selected validation jquery
- js create object with properties
- create nodejs new object
- Write an expression that will cause the following code to print "Equal" if the value of sensorReading is "close enough" to targetValue. Otherwise, print "Not equal". Ex: If targetValue is 0.3333 and sensorReading is (1.0/3.0), output is:
- reference body js
- how get parent element javascript
- login with gmail in react native
- how to parse json in java
- node if file exists
- status discored jks
- currying in javascript
- get div id javascript
- How to insert an item into an array at a specific index JavaScript
- js generator
- js scroll to id
- how to reverse a video in js
- how to generate a fibonacci sequence in javascript
- how to make back button react
- reactjs and webpack tutorial