JAVASCRIPT Exam Questions and Answers Latest Graded A+
1. Inside which HTML element do we put the JavaScript? - ✔✔<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> - ✔✔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 - ✔✔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"> - ✔✔<script src="xxx.js">
5. The external JavaScript file must contain the <script> tag. - ✔✔False
6. How do you write "Hello World" in an alert box? - ✔✔alert("Hello World");
7. How do you create a function in JavaScript? - ✔✔function myFunction()
8. How do you call a function named "myFunction"? - ✔✔myFunction()
9. How to write an IF statement in JavaScript? - ✔✔if (i == 5)