21. What will be printed when the following code runs?

var result = {
value: 7
};
console.log(JSON.stringify(result));

  • {}
  • {value: 7}
  • {“value”: 7}

Module quiz: Programming Paradigms

22. Variables declared using 'let' can be reassigned.

  • true
  • false

23. What will print out when the following code runs?

function scopeTest() {
var y = 44;

console.log(x);
}

var x = 33;
scopeTest();

  • null
  • undefined
  • 33
  • 44

24. What will print out when the following code runs?

class Cake {
constructor(lyr) {
this.layers = lyr;
}

getLayers() {
return this.layers;
}
}

class WeddingCake extends Cake {
constructor() {
super(2);
}

getLayers() {
return super.getLayers() * 5;
}
}

var result = new WeddingCake();
console.log(result.getLayers());

  • 0
  • 2
  • 5
  • 10

25. What will print out when the following code runs?

class Animal {

}

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

makeNoise() {
return this.noise;
}
}

class Wolf extends Dog {
constructor() {
super();
this.noise = "growl";
}
}

var result = new Wolf();
console.log(result.makeNoise());

  • bark
  • growl
  • undefined

26. Consider this code snippet: 'const [a, b] = [1,2,3,4] '. What is the value of b?

  • undefined
  • 1
  • 2
  • [1,2,3,4]

27. What value will be printed out when the following code runs?

function count(...food) {
console.log(food.length)
}

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

  • 2
  • 3
  • “Burgers”, “Fries”, null
  • “Burgers”, “Fries”, undefined

28. Which of the following are JavaScript methods for querying the Document Object Model? Select all that apply.

  • getElementsByClassName
  • getElementsById
  • getElementById
  • getElementByClassName
  • queryAllSelectors
  • querySelector

Shuffle Q/A 3

29. Which of the following methods convert a JavaScript object to and from a JSON string?

  • JSON.parse
  • JSON.stringify
  • JSON.fromString
  • JSON.toString

30. What will be the result of running this code?

const letter = "a"
letter = "b"

  • Uncaught TypeError: Assignment to constant variable 
  • b
  • a
  • Uncaught SyntaxError: Invalid or unexpected token

Leave a Reply