JavaScript Quiz Source Code

JavaScript Quiz Source Code

The JavaScript Quiz Source Code is developed using JavaScript, CSS and HTML, This JavaScript Quiz Using Arrays give a simple question to the user to be answer and after that the score will display and count the correct answer of the user.

A JavaScript Quiz For Beginners is designed for the beginners or the students who wants to learn in web developing. The HTML JavaScript Quiz Code is easy to understand the codes and also easy to manipulate by the users.

This JavaScript Quiz With Answers also includes a downloadable JavaScript Quiz Example Source Code for free, just find the downloadable source code below and click to start downloading.

I have here a suggested list of Best JavaScript Projects with Source Code Free to download and I’m sure this can help you to improve your skills in JavaScript programming and web development as a whole.

To start creating a JavaScript Quiz Source Code,  makes sure that you have any platform in creating a JavaScriptCSS,  bootstrap, and HTML installed in your computer, in my case I will use Sublime Text.

Steps on how to create a JavaScript Quiz Source Code

JavaScript Quiz Source Code

  • Step 1: Create a folder.

    First, create a folder and named it.
    create folder

  • Step 2: Open the folder in “Sublime Text”.

    Second ,after creating a folder, open it in “sublime text“.
    quiz open folder

  • Step 3: Create a html file.

    Third, create a “html” file and save it as “index.html
    quiz html file

  • Step 4: Create a css file.

    Fourth, create a “css” file and save it as “style.css
    quiz css file

  • Step 5: Create a javascript file.

    Fifth, create a “javascript” file and save it as “script.js
    quiz javascript file

The Code Given Below Is For The HTML File

<!DOCTYPE html>
<link href="style.css" rel="stylesheet">
<script src="main.js"></script>


<h1>Simple Javascript Quiz</h1>
<form id="quiz" name="quiz">
	<p>What is the Capital city of Drc (Democratic Republic of Congo) </p>
    <input type="radio" id="mc" name="question1" value="brazzaville">Brazzaville<br>
    <input type="radio" id="mc" name="question1" value="kinshasa">Kinshasa<br>
    <input type="radio" id="mc" name="question1" value="durban">Durban<br>

	<p>What is the Capital city of SA (South Africa) </p>

    <input type="radio" id="mc" name="question2" value="Rabat">Rabat<br>
    <input type="radio" id="mc" name="question2" value="Johannesburg">Johannesburg<br>
    <input type="radio" id="mc" name="question2" value="pretoria">Pretoria<br>

    <p>What is the Capital city of RCA (Republic Center Africa)</p>

    <input type="radio" id="mc" name="question3" value="bangui">Bangui<br>
    <input type="radio" id="mc" name="question3" value="bandundu">Bandundu<br>
    <input type="radio" id="mc" name="question3" value="luanda">Luanda<br>
    <input id="button" type="button" value="I'm finished!" onclick="check();">


<div id="after_submit">
	<p id="message"></p>
<p id="number_correct"></p>

<button onclick="myFunction()">Restart</button>


In this file which is the html file of the system project.

The Code Given Below Is For The JavaScript File

function check(){

	var question1 = document.quiz.question1.value;
	var question2 = document.quiz.question2.value;
	var question3 = document.quiz.question3.value;
	var correct = 0;

	if (question1 == "kinshasa"){
    if (question2 == "pretoria") {
    if (question3 == "bangui") {

    var messages = ["Good job", "Not bad", "You really need to do better"];
    var range;

     if (correct < 1){
     	 range = 2;

      if (correct > 0 && correct < 3){
     	 range = 1;

        if (correct > 2){
     	 range = 0;


   document.getElementById("message").innerHTML = messages[range];
   document.getElementById("number_correct").innerHTML = "you got " + correct + " correct.";


// reflesh page function

function myFunction() {

In this file which is the javascript file of the system project.

The Code Given Below Is For The CSS File

#after_submit {
	visibility: hidden;

In this file which is the css file of the system project.

Project Name :JavaScript Quiz
Project Platform :JavaScript
Programming Language Used:php,javascript,html,css
Developer Name
IDE Tool (Recommended):Sublime
Project Type :Web Application
Upload Date:November 17, 2020

Downloadable Source Code


This JavaScript Project With Source Code is simply in HTMLCSS, and JavaScript. Talking about the project, A user has to enter his/her name before entering the chatroom. After that, the user can easily share messages present in the chatroom. This project includes a lot of javascript for making the functioning of the project.

Related Articles


If you have any questions or suggestions about JavaScript Quiz Source Code , please feel free to leave a comment below.

Leave a Comment