Skip to content

Module quiz: Programming Paradigms :Programming with JavaScript (Meta React Native Specialization) Answers 2025

1. Variables declared using let can be reassigned.

✔️ true
❌ false


2. What will print out?

function scopeTest() {
var y = 44;
console.log(x);
}

var x = 33;
scopeTest();

✔️ 33
❌ null
❌ undefined
❌ 44


3. What will print out?

class Cake {
constructor(lyr) {
this.layers = lyr;
}
getLayers() { return this.layers; }
}
console.log(new Cake(2).getLayers());

✔️ 2
❌ 0
❌ 5
❌ 10


4. What will print out?

class Animal {}
class Dog extends Animal {
constructor() {
super();
this.noise = "bark";
}
}
console.log(new Dog().noise);

✔️ bark
❌ growl
❌ undefined


5. In const [a, b] = [1,2,3,4], what is b?

✔️ 2
❌ [1,2,3,4]
❌ undefined
❌ 1


6. What prints?

count("Burgers", "Fries", null);

✔️ 3
❌ 2
❌ “Burgers”, “Fries”, null
❌ “Burgers”, “Fries”, undefined


7. Which are DOM query methods? (Select all that apply)

✔️ getElementsByClassName
❌ getElementsById
✔️ getElementById
❌ getElementByClassName
❌ queryAllSelectors
✔️ querySelector


8. Methods for converting JS object ↔ JSON?

✔️ JSON.parse
✔️ JSON.stringify
❌ JSON.fromString
❌ JSON.toString


9. Result of:

const letter = "a"
letter = "b"

✔️ Uncaught TypeError: Assignment to constant variable
❌ b
❌ a
❌ SyntaxError


10. What is a constructor?

✔️ A function that is called to create an instance of an object.
❌ An instance of a class
❌ A specific created object
❌ An object literal



Summary Table

Q.No Correct Answer Explanation (Short)
1 true ✔️ let variables can be reassigned.
2 33 ✔️ x is global and accessible inside function.
3 2 ✔️ Constructor sets layers = 2.
4 bark ✔️ Dog sets this.noise = "bark".
5 2 ✔️ Array destructuring assigns second element to b.
6 3 ✔️ Rest parameter packs all 3 arguments.
7 getElementsByClassName, getElementById, querySelector ✔️ Valid DOM query methods.
8 JSON.parse, JSON.stringify ✔️ Used for JSON ↔ object conversion.
9 TypeError ✔️ const cannot be reassigned.
10 Constructor function ✔️ Creates object instances.