I passed the lesson, but please help me understand if I got right.
**Your code so far**
// Only change code below this line
class Vegetable { // make a class Vegetable
constructor (Vegetable) { // initializing the object Vegetable
this.name = Vegetable; // this refers to the object inside function (Vegetable), gives name property a value Vegetable
}
}
// Only change code above this line
const carrot = new Vegetable('carrot'); // making a new objective called carrot, new is copying the values of Vegetable objective and assigns new changes.
console.log(carrot.name); // Should display 'carrot' // carrot.name is now carrot.
I have added notes next to the commands tell me if I am right / wrong please ty
**Your browser information:**
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.110 Safari/537.36
Challenge: Use class Syntax to Define a Constructor Function
Link to the challenge: