Simple Quiz App
How do I make an simple quiz app?
What is a simple quiz app? How do you make a simple quiz app? This script and codes were developed by Matt Brody on 15 January 2023, Sunday.
Simple Quiz App - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Simple Quiz App</title> <link rel="stylesheet" href="css/style.css">
</head>
<body> <html>
<head> <title>Quiz App</title> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
</head>
<body> <div class="container"> <h1 class="title">Quiz App</h1> <div class="row"> <form class="col-sm-7"> <div class="form-group"> <h4 id="question0"></h2> <input id="answer0" type="text" class="form-control"> </div> <div class="form-group"> <h4 id="question1"></h2> <input id="answer1" type="text" class="form-control"> </div class="form-group"> <div> <h4 id="question2"></h2> <input id="answer2" type="text" class="form-control"> </div> <div class="form-group"> <h4 id="question3"></h2> <input id="answer3" type="text" class="form-control"> </div> <div> <h4 id="question4"></h2> <input id="answer4" type="text" class="form-control"> </div> <div> <h4 id="question5"></h2> <input id="answer5" type="text" class="form-control"> </div> <div> <h4 id="question6"></h2> <input id="answer6" type="text" class="form-control"> </div> <div> <h4 id="question7"></h2> <input id="answer7" type="text" class="form-control"> </div> <div> <h4 id="question8"></h2> <input id="answer8" type="text" class="form-control"> </div> <div> <h4 id="question9"></h2> <input id="answer9" type="text" class="form-control"> </div> <br> <button type="button" onclick="testResults()" class="btn btn-primary btn-lg">See Results</button> </form> <div class="col-sm-2 col-sm-offset-1"> <h1 class="correct">Correct: <span id="correct"></span></h1> <h1 class="incorrect">Incorrect: <span id="incorrect"></span></h1> </div> </div> </div>
</body>
</html> <script src="js/index.js"></script>
</body>
</html>
Simple Quiz App - Script Codes CSS Codes
.title { text-align: center; font-size: 50px;
}
.correct { color: green;
}
.incorrect { color: red;
}
h1.correct,
h1.incorrect { width: 250px;
}
Simple Quiz App - Script Codes JS Codes
var questions = [{ question: "what's 2 + 2?", answer: 4 }, { question: "What house was Harry Potter in?", answer: "gryffindor" }, { question: "What's 10 / 5?", answer: 2 }, { question: "Finish this sentence: winter is ______?", answer: "coming" }, { question: "Who is the youngest Lannister sibling", answer: "tyrion" }, { question: "Where does Jorah Mormont's family live?", answer: "bear island" }, { question: "How many dragons does Daenerys Targaryen have?", answer: 3 }, { question: "How many hands does Jaime Lannister have after book 3?", answer: 1 }, { question: "Did Tyrion commit regicide or patricide?", answer: "both" }, { question: "How many Direwolves do the starks find?", answer: 6 }
]
for (i = 0; i < questions.length; i++) { q = questions[i].question document.getElementById('question' + [i]).textContent = q
}
function testResults() { var correct = 0; var incorrect = 0; for (i = 0; i < questions.length; i++) { var answer = questions[i].answer var guess = document.getElementById('answer' + [i]).value var questionSpot = document.getElementById('question' + [i]) if (answer == guess) { questionSpot.className = 'correct' correct++ } else { questionSpot.className = 'incorrect' incorrect++ } } document.getElementById('correct').textContent = correct document.getElementById('incorrect').textContent = incorrect
}
Developer | Matt Brody |
Username | mattlbrody |
Uploaded | January 15, 2023 |
Rating | 3 |
Size | 2,550 Kb |
Views | 6,072 |
Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!
Name | Size |
Instagram API | 2,605 Kb |
Sorting into teams with Fireworks | 5,354 Kb |
Digital Clock | 2,037 Kb |
Gallery App with JS | 2,453 Kb |
Simple Quiz App | 2,550 Kb |
To Do List with Delete | 2,068 Kb |
Comment App | 2,137 Kb |
Zodiac App | 2,628 Kb |
To Do List | 1,982 Kb |
JavaScript Survey | 2,568 Kb |
Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!
Name | Username | Size |
SVG email test v2.0 | M_J_Robbins | 2,090 Kb |
Menubar compass mixin | Michaelparenteau | 4,925 Kb |
Tile Animation Thing | Frxnz | 4,332 Kb |
Menu | Vivi_Lai | 1,210 Kb |
A Pen by Taylor Vowell | Taylorvowell | 5,962 Kb |
CardMove | Thompsonemerson | 3,699 Kb |
JS Countdown Timer | Ayoungh | 2,435 Kb |
NeeilTimer | Neeilan | 2,836 Kb |
Canvas snow | Win7killer | 2,572 Kb |
Speech bubbles | Something | 1,547 Kb |
Surf anonymously, prevent hackers from acquiring your IP address, send anonymous email, and encrypt your Internet connection. High speed, ultra secure, and easy to use. Instant setup. Hide Your IP Now!