Simple Quiz App

Developer
Size
2,550 Kb
Views
6,072

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 Previews

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
}
Simple Quiz App - Script Codes
Simple Quiz App - Script Codes
Home Page Home
Developer Matt Brody
Username mattlbrody
Uploaded January 15, 2023
Rating 3
Size 2,550 Kb
Views 6,072
Do you need developer help for Simple Quiz App?

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!

Matt Brody (mattlbrody) Script Codes
Create amazing sales emails with AI!

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!