Skip to content

Module quiz: The Building Blocks of a Program :Programming with JavaScript (Meta React Native Specialization) Answers 2025

1. What data type is the variable x ?

var x = {};

✔️ Object
❌ Parameter
❌ Function


2. Output of the code?

try {
console.log('hello)
} catch(e) {
console.log('caught')
}

✔️ Uncaught SyntaxError: Invalid or unexpected token.
❌ Caught


3. What value is printed?

var burger = ["bun", "beef", "lettuce", "tomato sauce", "onion", "bun"];
console.log(burger[2]);

✔️ lettuce
❌ bun
❌ beef
❌ tomato sauce
❌ onion


4. How many methods does the bicycle object have?

var bicycle = {
wheels: 2,
start: function() {},
stop: function() {}
};

✔️ 2
❌ 1
❌ 3


5. Output of code?

try {
throw new Error();
console.log('Hello');
} catch(err) {
console.log('Goodbye');
}

✔️ Goodbye
❌ Hello


6. Missing bracket results in which error?

✔️ SyntaxError
❌ RangeError
❌ TypeError


7. Will the code execute and output a string?

add(3, "4");

✔️ Yes (result is “34”)
❌ No


8. What will be printed?

var result;
console.log(result);

✔️ undefined
❌ null
❌ 0


9. Output of code?

var str = "Hello";
str.match("jello");

✔️ null
❌ undefined
❌ empty string


10. Output of code?

try {
Number(5).toPrecision(300)
} catch(e) {
console.log("There was an error")
}

✔️ “There was an error”
❌ RangeError
❌ 5
❌ e

Summary Table

Q.No Correct Answer Explanation (Short)
1 Object ✔️ {} creates an object in JavaScript.
2 Uncaught SyntaxError ✔️ Missing quote causes error before try runs.
3 lettuce ✔️ burger[2] → index 2 = “lettuce”.
4 2 ✔️ Two methods: start() and stop().
5 Goodbye ✔️ Error is thrown → goes directly to catch.
6 SyntaxError ✔️ Missing bracket is a syntax issue.
7 Yes ✔️ Number + string → “34” (string).
8 undefined ✔️ Uninitialized variable defaults to undefined.
9 null ✔️ No match found → .match() returns null.
10 “There was an error” ✔️ Precision too large → RangeError → caught.