Use class Syntax to Define a Constructor Functio

Tell us what’s happening:
this.name = name will not pass the last test, however this.name = vegetable will…???

Your code so far


function makeClass() {
  "use strict";
  /* Alter code below this line */
class Vegetable {
  constructor(Vegetable){
    this.name = name ; 
}  
}
  /* Alter code above this line */
  return Vegetable;
}
const Vegetable = makeClass();
const carrot = new Vegetable('carrot');
console.log(carrot.name); // => should be 'carrot'

Your browser information:

User Agent is: Mozilla/5.0 (X11; Fedora; Linux x86_64; rv:67.0) Gecko/20100101 Firefox/67.0.

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/es6/use-class-syntax-to-define-a-constructor-function/

Well sure - this.name = name; will fail, because you haven’t created any variable named name. with the constructor,

class Vegetable {
  constructor(Vegetable){
    // here, you've created a variable named Vegetable by using that
    //   as a parameter in the constructor.
    this.name  = Vegetable;
    // this could potentially be confusing, as you have a class and a
    //   variable with the same name, and case, and everything.
  }
  //  the rest of Vegetable
}

So in that, the constructor gets a parameter, which you are calling Vegetable. If you wanted to do this.name = name, then simply change the parameter in the constructor from Vegetable to name.

ok now I got it, thanks man