Tell us what’s happening:
I am trying to solve this challenge, but when I run the code i get the following error:
Cannot set property ‘name’ of undefined
Can anybody suggest anything?
Your code so far
function makeClass() {
"use strict";
var carrot;
carrot.name="carrot";
return message
}
const Vegetable = makeClass()
const carrot = new Message("creating new Ball")
console.log(carrot.name)
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.132 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/