11. What will print out when the following code runs?
var x;
if(x === null) {
console.log("null");
} else if(x === undefined) {
console.log("undefined");
} else {
console.log("ok");
}
- null
- undefined
- ok
12. What will print out when the following code runs?
throw new Error();
console.log("Hello");
- Hello
- Nothing will print out.
Module quiz: The Building Blocks of a Program
14. What will be the output of running the following code?
try {
console.log('hello)
} catch(e) {
console.log('caught')
}
- Uncaught SyntaxError: Invalid or unexpected token.
- Caught
15. What value is printed when the following code runs?
var burger = ["bun", "beef", "lettuce", "tomato sauce", "onion", "bun"]
console.log(burger[2]);
- bun
- beef
- lettuce
- tomato sauce
- onion
16. In the following code, how many methods does the bicycle object have?
var bicycle = {
wheels: 2,
start: function() {
},
stop: function() {
}
};
- 1
- 2
- 3
17. When the following code runs, what will print out?
try {
throw new Error();
console.log('Hello');
} catch(err) {
console.log('Goodbye');
}
- Hello
- Goodbye
18. If you mis-type some code in your JavaScript, what kind of error will that result in?
- RangeError
- SyntaxErrror
- TypeError
Shuffle Q/A 2
19. Will the following code execute without an error?
function add(a, b) {
console.log(a + b)
}
add(3, "4");
- Yes
- No
20. What will be printed when the following code runs?
var result;
console.log(result);
- undefined
- null
- 0