-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJsExer.html
259 lines (248 loc) · 13 KB
/
JsExer.html
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
<!DOCTYPE html>
<html lang="en">
<head>
<!-- ad sense tag-->
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-1733919132650092"
crossorigin="anonymous"></script>
<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-FBJL1SB5QM"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag() { dataLayer.push(arguments); }
gtag('js', new Date());
gtag('config', 'G-FBJL1SB5QM');
</script>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="description"
content="CodingNation provides exercises to pratice and learn coding. Coding Nation Execise are used to enhance your coding skills">
<meta name="keywords"
content="coding, programming, tutorial, learn, HTML, CSS, JavaScript, Python, resources, free, code tutorial, coding exercises, coding challenges, learn to code, coding skills">
<meta name="author" content="coding-nation">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="robots" content="index, follow">
<link rel="icon" type="image/png" sizes="32x32" href="../images/favicon.png">
<title>JavaScript Exercise</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha3/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-KK94CHFLLe+nY2dmCWGMq91rCGa5gtU4mk92HdvYe+M/SXH301p5ILy+dN9+nJOZ" crossorigin="anonymous" />
<link rel="stylesheet" href="../Styles/Exercise.css">
</head>
<body>
<!--navigation bar-->
<header class="fixed-navbar">
<!--navigation bar-->
<nav class="navbar navbar-expand-md navbar-dark bg-dark fixed-top">
<div class="container-fluid">
<a class="navbar-brand" href="../index.html">CodingNation</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav"
aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNav">
<ul class="navbar-nav ms-auto" id="navbarNavLinks">
<li class="nav-item">
<a class="nav-link" href="../index.html">Home</a>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown"
aria-controls="navbarNav" aria-expanded="false"
aria-label="Toggle navigation">Courses</a>
<ul class="dropdown-menu">
<li>
<a class="dropdown-item" href="../Python.html">Python</a>
</li>
<li>
<a class="dropdown-item" href="../React.html">React JS</a>
</li>
<li>
<a class="dropdown-item" href="../html.html">HTML</a>
</li>
<li><a class="dropdown-item" href="../css.html">CSS</a></li>
<li>
<a class="dropdown-item" href="../jascri.html">JavaScript</a>
</li>
<li><a class="dropdown-item" href="../cpro.html">C</a></li>
<li>
<a class="dropdown-item" href="../java.html">Java</a>
</li>
<li><a class="dropdown-item" href="../php.html">PHP</a></li>
</ul>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" role="button"
data-bs-toggle="dropdown">Practice</a>
<ul class="dropdown-menu">
<li>
<a class="dropdown-item" href="../HTMLQuiz.html" target="_blank">HTML Quiz</a>
</li>
<li>
<a class="dropdown-item" href="../CSSQuiz.html" target="_blank">CSS Quiz</a>
</li>
<li>
<a class="dropdown-item" href="../JSQuiz.html" target="_blank">JavaScript Quiz</a>
</li>
<li>
<a class="dropdown-item" href="../CQuiz.html" target="_blank">C Quiz</a>
</li>
<li>
<a class="dropdown-item" href="../JAVAQuiz.html" target="_blank">Java Quiz</a>
</li>
</ul>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" role="button"
data-bs-toggle="dropdown">Exercises</a>
<ul class="dropdown-menu">
<li>
<a class="dropdown-item" href="../HTMLExer.html" target="_blank">HTML Exercise</a>
</li>
<li>
<a class="dropdown-item" href="../CSSExer.html" target="_blank">CSS Exercise</a>
</li>
<li>
<a class="dropdown-item" href="../JsExer.html" target="_blank">JavaScript
Exercise</a>
</li>
<li>
<a class="dropdown-item" href="../CExer.html" target="_blank">C Exercise</a>
</li>
<li>
<a class="dropdown-item" href="../JAVAExer.html" target="_blank">Java Exercise</a>
</li>
</ul>
</li>
<li class="nav-item">
<a class="nav-link" href="../codebot.html" target="_blank">CodeBot</a>
</li>
<li class="nav-item">
<a class="nav-link" href="../Editor.html" target="_blank">Editor</a>
</li>
<li class="nav-item">
<a class="nav-link" href="../About.html">About</a>
</li>
</ul>
</div>
</div>
</nav>
</header>
<div class="container">
<h1 class="float-start">Exercise</h1>
<p id="title"></p>
<div class="questions" id="questions"></div>
<div class="bt">
<button type="submit" id="submit">Submit</button>
<button id="next">Next</button>
<button id="wrong">Try Again</button>
<button id="showAnswer">Show Answer</button>
</div>
</div>
<!-- Footer Section -->
<footer class="container-fluid text-center">
<hr />
<span class="bi bi-caret-up" onclick="topFunction()"></span>
<p>Copyright © 2023 CodingNation. All rights reserved. <br /></p>
<p>
Trademark ™ CodingNation
<a href="https://www.coding-nation.com/">www.coding-nation.com</a>
</p>
</footer>
<script>
const submit = document.getElementById("submit");
const next = document.getElementById("next");
const wrong = document.getElementById("wrong");
const questions = document.getElementById("questions");
const head = document.getElementById("title");
const showAnswer = document.getElementById("showAnswer");
const quiz = [
{
title: `Create a variable called carName, assign the value Volvo to it.`,
question: `<p>var <input style="width:80px;" type="text" maxlength="42"> = "Volvo";</p> `,
answer: `carName`,
},
{
title: `Multiply 10 with 5, and print the result:`,
question: `<p>let x = 10;<br> let y = 20;<br>
console.log(x <input type="text" maxlength="2"> y);</p> `,
answer: `*`,
},
{
title: `Create a variable called x, assign the value 10 to it.`,
question: `<p>let <input type="text" maxlength="2"> = 10;</p> `,
answer: `x`,
},
{
title: `Divide 10 with 5, and print the result:`,
question: `<p>let x = 10;<br> let y = 20;<br>
console.log(x <input type="text" maxlength="2"> y);</p> `,
answer: `/`,
},
{
title: `Add 10 with 5, and print the result:`,
question: `<p>let x = 10;<br> let y = 20;<br>
console.log(x <input type="text" maxlength="2"> y);</p> `,
answer: `+`,
},
{
title: `Subtract 10 with 5, and print the result:`,
question: `<p>let x = 10;<br> let y = 20;<br>
console.log(x <input type="text" maxlength="2"> y);</p> `,
answer: `-`,
},
{
title: `Execute the function named myFunction.`,
question: `<p>function myFunction() {<br>
alert("Hello World!");<br>
}<br>
<input style="width:140px;" type="text" maxlength="25">;</p> `,
answer: `myFunction()`,
},
{
title: `Make the function return "Hello World".`,
question: `<p>function myFunction() {<br>
<input style="width:200px;" type="text" maxlength="25">;<br>
}<br></p> `,
answer: `return "Hello World"`,
},
{
title: `Make the function display "Hello" in the inner HTML of an element with the ID "demo".`,
question: `<p>function myFunction() { <br>
document.getElementById("demo").<input style="width:150px;" type="text" maxlength="25"> = "Hello World";<br>
}<br></p> `,
answer: `innerHTML`,
},
{
title: `The button element should do something when someone clicks on it. Try to fix it!`,
question: `<p><button <input style="width:100px;" type="text" maxlength="25"> ="alert('Hello')">Click me.</button><br>
</p> `,
answer: `onclick`,
},
{
title: `The div element should turn red when someone moves the on mouse over it.`,
question: `<p><div <input style="width:100px;" type="text" maxlength="25"> ="this.style.backgroundColor='red'">myDIV.</div><br>
</p> `,
answer: `onmouseover`,
},
{
title: `Fix the if statement to alert "Hello World" if x is greater than y.`,
question: `<p>if(<input style="width:80px;" type="text" maxlength="25"> ){<br>
alert("Hello World");<br>
}</p> `,
answer: `x > y`,
},
{
title: `Fix the if statement to alert "Hello World" if x is less than y, else alert goodbye.`,
question: `<p>if(<input style="width:80px;" type="text" maxlength="25"> ){<br>
alert("Hello World");<br>
}else{<br>
alert("goodbye")<br>}</p> `,
answer: `x < y`,
},
];
</script>
<script src="../Scripts&xml/Exercise.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha3/dist/js/bootstrap.bundle.min.js"
integrity="sha384-ENjdO4Dr2bkBIFxQpeoTz1HIcje39Wm4jDKdf19U8gI4ddQ3GYNS7NTKfAdVQSZe"
crossorigin="anonymous"></script>
</body>
</html>