Use class Syntax to Define a Constructor-Function

Tell us what’s happening:

Your code so far


function makeClass() {
  "use strict";
  /* Alter code below this line */
  class vegetable {
    constructor(name) {
      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'

run the tests: result
Vegetable is not defined
Vegetable is not defined
Vegetable is not defined
Vegetable is not defined
// tests completed

Please tell me what wrong with this code.

Your browser information:

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

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

1 Like

Looks like you just need to capitalize the “v” in vegetable inside of the makeClass function

4 Likes

Thank you so much frankRose1

I have my class name as Vegetable i.e with with capital “V”.
Still am getting error.
Please help.

This line should not be commented:

//const Vegetable = makeClass();