I passed but, i still don't understand : Use class Syntax to Define a Constructor Function

Tell us what’s happening:

This constructor is invoked when new is called to create a new object.
What do the mean with that ? why do we use a constructor?

UpperCamelCase should be used by convention for ES6 class names, as in SpaceShuttle used above.
Why so far we just where okay with cameCase?

Very confusing can someone explain?

Your code so far


// Only change code below this line
class Vegetable{
constructor(name)  {
this.name = name;
}
}
// Only change code above this line

const carrot = new Vegetable('carrot');
console.log(carrot.name); // Should display 'carrot'

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.125 Safari/537.36.

Challenge: Use class Syntax to Define a Constructor Function

Link to the challenge:

UpperCamelCase should be reserved for class names, and the constructor is used to create another object with properties of what you input to the arguments when you call the new. Let me know if you need further help.

2 Likes