
Midterm #2 Review Questions, CMSC198N
These questions will help you prepare for the midterm. Solutions will not be provided, however,
you are welcome to discuss your solutions with TAs and your instructor during office hours. Do
not use a computer when writing JavaScript programs; write your solution on paper then
verify your solutions with the computer. That is the best way for you to prepare for the exam.
Problem 1
1. (2 pts) Which of the following is considered an invalid variable name in JavaScript?
a) realHappy# b) HoT
c) temperature d) To2he
2. (2 pts) Which of the following is not a reserved word?
a) if b) do
c) function d) segmentVar
3. (2 pts) In JavaScript there is only one approach to specify comments.
a) true b) false
4. (2 pts) The following code represents an infinite loop.
var t = 1;
while (t == 1) ;
a) true b) false
5. (2 pts) JavaScript is another name for the Java Programming language.
a) true b) false
6. (2 pts) Which of the following allow us to determine the current date in JavaScript?
a) new GMTVar() b) new Date()
c) DateAndTime() d) new Time()
7. (2 pts) The expression x++ is equivalent to:
a) x = x - 1 b) x = x + 1
c) x = x * 10 d) x = x / 10
8. (2 pts) The body of a do while statement will always be executed at least twice.
a) true b) false
9. (2 pts) The body of a while statement will always be executed at least once.
a) true b) false
10. (2 pts) A call to the prompt function returns a string.
a) true b) false