W3SCHOOLS JAVASCRIPT QUIZ
1. Inside which HTML element do we put the JavaScript? - Correct Answers -<script>
2. What is the correct JavaScript syntax to change the content of the HTML element
below?
<p id="demo">This is a demonstration.</p> - Correct Answers -
document.getElementById("demo").innerHTML = "Hello World!";
3. Where is the correct place to insert a JavaScript?
The <body> section
Both the <head> section and the <body> section are correct
The <head> section - Correct Answers -Both the <head> section and the <body>
section are correct
4. What is the correct syntax for referring to an external script called "xxx.js"?
<script name="xxx.js">
<script src="xxx.js">
<script href="xxx.js"> - Correct Answers -<script src="xxx.js">
9. How to write an IF statement in JavaScript? - Correct Answers -if (i == 5)
10. How to write an IF statement for executing some code if "i" is NOT equal to 5? -
Correct Answers -if (i != 5)
11. How does a WHILE loop start? - Correct Answers -while (i <= 10)
5. The external JavaScript file must contain the <script> tag. - Correct Answers -False
6. How do you write "Hello World" in an alert box? - Correct Answers -alert("Hello
World");
7. How do you create a function in JavaScript? - Correct Answers -function
myFunction()
8. How do you call a function named "myFunction"? - Correct Answers -myFunction()
12. How does a FOR loop start? - Correct Answers -for (i = 0; i <= 5; i++)
1. Inside which HTML element do we put the JavaScript? - Correct Answers -<script>
2. What is the correct JavaScript syntax to change the content of the HTML element
below?
<p id="demo">This is a demonstration.</p> - Correct Answers -
document.getElementById("demo").innerHTML = "Hello World!";
3. Where is the correct place to insert a JavaScript?
The <body> section
Both the <head> section and the <body> section are correct
The <head> section - Correct Answers -Both the <head> section and the <body>
section are correct
4. What is the correct syntax for referring to an external script called "xxx.js"?
<script name="xxx.js">
<script src="xxx.js">
<script href="xxx.js"> - Correct Answers -<script src="xxx.js">
9. How to write an IF statement in JavaScript? - Correct Answers -if (i == 5)
10. How to write an IF statement for executing some code if "i" is NOT equal to 5? -
Correct Answers -if (i != 5)
11. How does a WHILE loop start? - Correct Answers -while (i <= 10)
5. The external JavaScript file must contain the <script> tag. - Correct Answers -False
6. How do you write "Hello World" in an alert box? - Correct Answers -alert("Hello
World");
7. How do you create a function in JavaScript? - Correct Answers -function
myFunction()
8. How do you call a function named "myFunction"? - Correct Answers -myFunction()
12. How does a FOR loop start? - Correct Answers -for (i = 0; i <= 5; i++)