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>
<html>
<head>
<title>Quiz</title>
<link href="style.css" rel="stylesheet">
<script src="main.js"></script>

</head>
<body>

<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>
</br>
    <input id="button" type="button" value="I'm finished!" onclick="check();">

</form>

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

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


</body>
</html>

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"){
		correct++;
}
    if (question2 == "pretoria") {
    	correct++;
}
    if (question3 == "bangui") {
    	correct++
    }  

    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("after_submit").style.visibility="visible";


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

}

// reflesh page function

function myFunction() {
    location.reload();
}

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.

ABOUT PROJECTPROJECT DETAILS
Project Name :JavaScript Quiz
Project Platform :JavaScript
Programming Language Used:php,javascript,html,css
Developer Name :itsourcecode.com
IDE Tool (Recommended):Sublime
Project Type :Web Application
Database:None
Upload Date:November 17, 2020

Downloadable Source Code

Summary

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

Inquiries

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

Leave a Comment