You have called the following statement:

console.log(car.make);

What declaration should precede the statement so that the text Jeep appears in the console as a result of its execution?

  • var car = {'Jeep'};
  • let car = [make: 'Jeep', model: 'Cherokee'];
  • let car = {make: 'Jeep', model: 'Cherokee'};
  • let car = [make: 'Jeep'];
Explanation & Hint:

To have the text “Jeep” appear in the console as a result of executing the statement console.log(car.make);, you should use an object declaration that defines make as a property of the object car. The correct syntax in JavaScript to define such an object is with curly braces {}, specifying properties and their values. Therefore, the correct declaration is:

let car = {make: 'Jeep', model: 'Cherokee'};

This declaration defines car as an object with properties make and model, where make is set to 'Jeep'. When console.log(car.make); is executed, it will access the make property of the car object and print “Jeep” to the console.

Leave a Reply