Commit 5d683400 authored by Ben Anderson's avatar Ben Anderson

Initial Commit

parents
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
<script defer src="./index.js"></script>
</head>
<body>
<p><strong>1.</strong> What is 140 % 9?</p>
<input class="answer" type="text" />
<p><strong>2.</strong> Is string a primitive or reference type in JS?</p>
<input class="answer" type="text" />
<p><strong>3.</strong> What is the global JS object in the browser?</p>
<input class="answer" type="text" />
<p><strong>4.</strong> True or False: Javascript is strictly typed</p>
<input class="answer" type="text" />
<p><strong>5.</strong> What JS keyword lets you skip a round of looping?</p>
<input class="answer" type="text" />
<p>
<strong>6.</strong> What is the name of JS's built in http request API?
</p>
<input class="answer" type="text" />
<button id="btn" type="submit">Submit</button>
</body>
</html>
function gradeQuiz(answerStr) {
switch(answerStr) {
case "5 primitive window false continue fetch ":
console.log("CORRECT")
document.body.style.background = "green";
break;
case "never going to give you up ":
console.log("rick roll")
document.body.style.backgroundImage = `url("https://nerdist.com/wp-content/uploads/2020/07/maxresdefault.jpg")`;
break;
default:
console.log("WRONG");
document.body.style.background = "red";
break;
}
}
document.getElementById("btn").addEventListener("click", () => {
const answers = document.getElementsByClassName("answer");
let results = ""
for (let answer of answers) {
// console.log(ans)
results += answer.value + ' ';
}
console.log(results);
gradeQuiz(results);
});
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment