2.1. JavaScript PreTest¶
The following Quiz is for me to assess what you already know about JavaScript. It will not count towards you final grade, nor will I look down on you if you don’t know any of it. The point is to not waste time covering things that people already know. It will also provide a basis at the end to measure how much you have learned!
- <javascript>
- <js>
- <scripting>
- <script>
- document.getElementById("demo").innerHTML = "Hello World!";
- #demo.innerHTML = "Hello World!";
- document.getElementByName("p").innerHTML = "Hello World!";
- document.getElement("p").innerHTML = "Hello World!";
- True
- False
- function:myFunction()
- function myFunction()
- function = myFunction()
- call function myFunction()
- myFunction()
- call myFunction()
- if (i == 5)
- if i = 5 then
- if i = 5:
- if i == 5 then
- while i = 1 to 10
- while (i <= 10; i++)
- while (i <= 10)
- for (i = 0; i <= 5)
- for (i = 0; i <= 5; i++)
- for i = 1 to 5
- for (i <= 5; i++)
- var colors = 1 = ("red"), 2 = ("green"), 3 = ("blue")
- var colors = (1:"red", 2:"green", 3:"blue")
- var colors = ["red", "green", "blue"]
- var colors = "red", "green", "blue"
- True
- False
- onchange
- onmouseover
- onclick
- onmouseclick
- v carName;
- var carName;
- variable carName;
- It is an error
- 'a', 'b', 'c' - each on their own line
- 1, 2, 3 - each on their own line
- 0, 1, 2 - each on their own line
- It is an error
- 'a', 'b', 'c' - each on their own line
- 1, 2, 3 - each on their own line
- 0, 1, 2 - each on their own line
pretest-1: Inside which HTML element do we put the JavaScript?
pretest-2: What is the correct JavaScript syntax to change the content of the HTML element below?
<p id="demo">This is a demonstration.</p>
pretest-3: The external JavaScript file must contain the <script>
tag.
pretest-4: How do you create a function in JavaScript?
pretest-5: How do you call a function named “myFunction”?
pretest-6: How to write an IF statement in JavaScript?
pretest-7: How does a WHILE loop start?
pretest-8: How does a FOR loop start?
pretest-9: What is the correct way to write a JavaScript array?
pretest-10: JavaScript is the same as Java.
pretest-11: Which event occurs when the user clicks on an HTML element?
pretest-12: How do you declare a JavaScript variable?
pretest-13: What is the output of the following?
l = ['a', 'b', 'c']
for (var i of l) {
console.log(i)
}
pretest-14: What is the output of the following?
l = ['a', 'b', 'c']
for (var i in l) {
console.log(i)
}
Write a function called isEven that takes a single number as a parameter and returns true if the number is even. Otherwise it should return false.