Skip to content

Latest commit

 

History

History
233 lines (154 loc) · 5.28 KB

File metadata and controls

233 lines (154 loc) · 5.28 KB

Week One Quiz

Question 1

Every valid web page can be represented as a tree. This tree is referred to as the

1) JavaScript
2) DOM
3) API

ANS: 2) DOM


Question 2

JavaScript uses what kind of interface to access the DOM structure?

1) CSS3
2) an API
3) HTML5

ANS: 2) an API


Question 3

Which of these is not valid? (Hint, pay attention to if the method should return one thing, or many things...)

1) document.getElementsById(idName)
2) document.getElementsByClassName(className)
3) document.getElementsByTagName(tagName)

ANS: 1) document.getElementsById(idName)


Question 4

Which of the following is not a valid method for generating output to the screen?

1) prompt
2) alert
3) document.write
4) print

ANS: 4) print


Question 5

Which of these options does NOT require the use of parentheses?

1) innerHTML
2) alert
3) document.write
4) console.log

ANS: 1) innerHTML


Question 6

Which of the following does not generate output directly to the screen?

1) document.write(message);
2) element.innerHTML = message;
3) console.log(message);

ANS: 3) console.log(message);


Question 7

How does prompt differ from alert?

1) Only prompt uses parentheses.
2) The prompt will return a value, alert does not.
3) The alert will return a value, prompt does not.
4) Only alert uses parentheses.

ANS: 2) The prompt will return a value, alert does not.


Question 8

Variables allow you to save data.

1) True
2) False

ANS: 1) True


Question 9

In JavaScript the keyword ___________ is used to declare a variable.

ANS: var


Question 10

What does it mean that variables are case-sensitive?

1) That all variables must use uppercase letters
2) That the computer does not think that the variables name and Name are the same thing.
3) That all variables must use lowercase letters

ANS: 2) That the computer does not think that the variables name and Name are the same thing.


Question 11

Which of the following is not a valid variable name?

1) variable1
2) variableOne
3) 1variable
4) oneVariable

ANS: 3) 1variable


Question 12

Which of the following is not a valid variable name?

1) variable$2
2) variable-2
3) variable_2

ANS: 2) variable-2


Question 13

What does mnemonic mean?

1) That variable names should start with lowercase letters and use uppercase letters if the variable has multiple parts, e.g. firstName.
2) That variable names should be as short as possible, preferably with no more than two or three characters.
3) That variable names should help describe the value being stored.

ANS: 3) That variable names should help describe the value being stored.


Question 14

What is wrong with this code?

var name = "Mike";
"Colleen" = name;

1) It is illegal to change the value stored in a variable.
2) This code is illegal and it doesn't make sense to have a non-variable (also called a constant) in the left-hand side (LHS) of an assignment statement.
3) The variable declaration is illegal.

ANS: 2) This code is illegal and it doesn't make sense to have a non-variable (also called a constant) in the left-hand side (LHS) of an assignment statement.


Question 15

What value is stored in name if the person hits the Cancel button on a prompt?

var name = prompt("What is your name?");

ANS: null


Question 16

What value is stored in name if the person hits the Okay button on a prompt before entering anything?

var name = prompt("What is your name?");

1) an empty string ("")
2) undefined
3) exception

ANS: 1) an empty string ("")


Question 17

To create a String variable, use quotes around the value you want to save.

1) True
2) False

ANS: 1) True


Question 18

Boolean variables store either true or false.

1) True
2) False

ANS: 1) True


Question 19

When a function returns a node from the DOM, it is of type

1) Number
2) String
3) Boolean
4) Object

ANS: 4) Object


Question 20

A function that wants to return multiple values at once (such as document.getElementsByTagName) will return a/an

1) Number
2) String
3) Array

ANS: 3) Array


Question 21

Which of the following is not a valid operator?

1) =+
2) +=
3) ==
4) ++
5) --

ANS: 1) =+


Question 22

What value is returned by 17 % 5?

ANS: 2


Question 23

What is the difference between == and === ?

1) The == operator only checks for equivalent values, not equivalent type too.
2) The === operator only checks for equivalent values,  not equivalent type too.
3) The == operator is the assignment operator, while === is the equality operator.

ANS: 1) The == operator only checks for equivalent values, not equivalent type too.


Question 24

What is the logical operator for AND?

ANS: &&


Question 25

Which tag is used to let the browser know that it is about to see JavaScript code?

1) <script>
2) <head>
3) <javascript>

ANS: 1) <script>


Question 26

JavaScript code must be placed in the section of the document.

1) True
2) False

ANS: 2) False