Use class Syntax

Tell us what’s happening:

what’s wrong with the code?

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'

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 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

JavaScript is case-sensitive. Review your code carefully and make sure you do not have any typos.

1 Like