5.13. Javascript Final Quiz¶
For the following questions, you may use the textbook or your notes. You may not google other references. You have 30 minutes to complete both parts of the quiz. Make sure that you complete the multiple choice questions first, and click “Finish Exam” before you go on to do the coding question.
- <script>
- Yes
- <scripting>
- close
- <style>
- style is for CSS
- <javascript>
- no
- #demo.innerHTML = "Hello World!";
- No, this is an error
- document.appendChild("p").innerHTML = "Hello World!";
- No
- document.getElement("p").innerHTML = "Hello World!";
- No
- document.querySelector("#demo").innerHTML = "Hello World!";
- Yes!
- onchange
- No, this would work only with input elements
- onclick
- Yes
- onmouseover
- No, this event does not require a click
- onmouseclick
- No, this is not an event
- document.body.ol.innerHTML = "<li>"
- No, There is no document.body.ol
- myLi = "#newli"
- This just assigns a string to a variable
- document.createElement("li")
- Yes
- myOl.appendChild("li")
- No, appendChild does not create an element
- True
- No Feedback
- False
- No Feedback
- msg("Hello World");
- No, there is no msg function
- console.log("Hello World");
- This adds a message to the javascript console
- alertBox("Hello World");
- There is no alertBox function
- alert("Hello World");
- Yes!
- myFunction = function()
- Yes
- myFunction()
- No, this calls myFunction
- function:myFunction()
- No, the : is wrong
- <script>function = {}</script>
- No, this is syntactically all wrong
- myTr.addParent(myRow);
- There is no addParent function
- document.body.innerHTML = "<tr><tr></tr></td>"
- No, this changes the entire body
- myRow.appendChild(myTr);
- Yes
- myTr.appendChild(myRow);
- No, you have parent and child backward
- <script name="xxx.js">
- No, name is mainly used with input tags
- <script src="xxx.js">
- Yes
- <script href="xxx.js">
- href is used with the link tag
- <link href="xxx.js">
- No, link is used for including css
- a1
- No, a1 is the grand parent
- a2
- Yes
- a3
- No, a3 is a sibling
- a5
- No, a5 is the child of a4
Q-1: Inside which HTML tag do we put Javascript code?
Q-2: Which is the correct statement to change the following: <p id="demo">This is a demonstration.</p>
Q-3: Which event occurs when the user clicks on an HTML element?
Q-4: Which javascript statement correctly creates a new entry for a list?
Q-5: An external JavaScript file must contain the <script>
tag.
Q-6: How do you write “Hello World” in an alert box?
Q-7: How do you create a function in JavaScript?
Q-8: Which statement correctly adds a tr element named myTr to the DOM tree?
Q-9: What is the correct syntax for referring to an external script called “xxx.js”?
Q-10: Given the following HTML source, what is the parent of the element with the selector “#a4”
<body>
<table id="a1">
<tr id="a2">
<td id="a3">Hello</td>
<td id="a4"><img id="a5" src="hello.jpg"></td>
</tr>
</table>
</body>
5.13.1. Programming Question¶
Write a function that each time it is clicked will do the following:
Turn the background of the page light blue.
Add another H1 to the page that says “So Long 130”
Changes the font color for the H1 to red
By each time, I mean that if the button is clicked 10 times there should be 10 H1’s on the page.