-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRicePurityTestScript.js
More file actions
37 lines (27 loc) · 1.03 KB
/
RicePurityTestScript.js
File metadata and controls
37 lines (27 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
//function to calculate the user's score
function calculateScore(){
//sets the maximum score as 100
const checkboxes = document.querySelectorAll('input[type="checkbox"]');
let score = 100;
//for each checkbox that is selected, 1 is taken from the total score
checkboxes.forEach((checkbox) => {
if (checkbox.checked){
score--;
}
});
//displays score
const resultDiv = document.getElementById('result');
resultDiv.textContent = `Your purity score is: ${score}`;
resultDiv.style.display = 'block';
}
//function to clear the checkboxes
function clearBoxes(){
//makes it so that the checkboxes being checked is made false
const questions = document.querySelectorAll('input[type = "checkbox"]')
questions.forEach((question) => {
question.checked = false;
});
//clears the screen of checked checkboxes and score
const resultDiv = document.getElementById('result');
resultDiv.style.display = 'none';
}