Skip to content

Commit

Permalink
Merge pull request #6 from avionicharshit-byte/main
Browse files Browse the repository at this point in the history
added quiz question in index.html file and updated script.js file
  • Loading branch information
Sar-taj107 committed Oct 5, 2023
2 parents 59472c5 + 4c25b8c commit 8c6c989
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
22 changes: 20 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
<p class="subtitle">Quiz on WebDev - Basics </p>
</div>


<form class="quiz-form">
<div class="question">
<p>1. Inside which HTML element do we put the JavaScript?</p>
Expand Down Expand Up @@ -298,6 +297,26 @@
<label for="">Application Protocol Integration</label>
</div>
</div>

<div class="question">
<p>15. Which of the following is not a valid way to declare a variable in JavaScript?</p>
<div class="option">
<input type="radio" name="q15" id="" value="A" checked >
<label for="">var myVariable = 10</script></label>
</div>
<div class="option">
<input type="radio" name="q15" id="" value="B">
<label for="">let myVariable = 10</label>
</div>
<div class="option">
<input type="radio" name="q15" id="" value="C">
<label for="">const myVariable = 10</label>
</div>
<div class="option">
<input type="radio" name="q15" id="" value="D" >
<label for="">myVariable = 10</label>
</div>
</div>

<div class="result hide">
<p></p>
Expand All @@ -314,5 +333,4 @@
</main>
<script src="script.js"></script>
</body>

</html>
7 changes: 4 additions & 3 deletions script.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

const correctAnswer = ["D", "B", "C", "B", "D", "A", "B", "D", "A", "B", "A", "C", "B", "C"];
const correctOptions = ["D", "B", "C", "B", "D", "A", "B", "D", "A", "B", "A", "C", "B", "C"];
const correctAnswer = ["D", "B", "C", "B", "D", "A", "B", "D", "A", "B", "A", "C", "B", "C", "D"];
const correctOptions = ["D", "B", "C", "B", "D", "A", "B", "D", "A", "B", "A", "C", "B", "C", "D"];

const form = document.querySelector(".quiz-form");
const result = document.querySelector(".result");
Expand All @@ -9,6 +9,7 @@ const questions = document.querySelectorAll(".question");
form.addEventListener("submit", (event) => {
event.preventDefault();


let score = 0;
const userAnswers = [
...document.querySelectorAll("input[type=radio]:checked"),
Expand Down Expand Up @@ -37,4 +38,4 @@ form.addEventListener("submit", (event) => {
result.querySelector(
"p"
).textContent = `You scored ${score}/${userAnswers.length}!`;
});
});

0 comments on commit 8c6c989

Please sign in to comment.