ES6 - Use class Syntax to Define a Constructor Function

Tell us what’s happening:
Describe your issue in detail here.

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/113.0.0.0 Safari/537.36

Challenge: ES6 - Use class Syntax to Define a Constructor Function

Link to the challenge:

this entire course is making ZERO sense. they start off giving you a simple example, then for the exercise part they expect you to know how to solve a much more complicated task than the actual explanation. it kind of goes like this so far in the javascript course;

step 1) grab a welding torch
step 2) put on your welding mask
step 3) build a space shuttle

steps 1 and 2 define the explanation of the lesson while step 3 defines the exercise they are asking you to complete. for example, using the this.X property was never covered nor explained prior. almost every lesson about arrays and objects had to be completed by using chatGPT or the guide and copy and pasting the solution inside the console as freecodecamp javascripts course is poorly written to understand as a beginner. it goes from very low difficulty to extremely hard to complete in a very fast timeframe (As a Beginner).

Perhaps the keyword “this” deserve its own topic ?

When i read more at JavaScript Classes, the usage of “this” is not explained either.

But, i feel the keyword “this” is such a beauty of javascript, as it is intuitively self-explanatory for me. :rofl: Just an opinion.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.