Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
J
js-practice
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Ben Anderson
js-practice
Commits
5d683400
Commit
5d683400
authored
Apr 09, 2021
by
Ben Anderson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Initial Commit
parents
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
61 additions
and
0 deletions
+61
-0
index.html
index.html
+33
-0
index.js
index.js
+28
-0
No files found.
index.html
0 → 100644
View file @
5d683400
<!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>
index.js
0 → 100644
View file @
5d683400
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
);
});
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment