Tell us what’s happening:
I’m using the right solution from “HINT” but my code is not passing the test.:
// running tests
carrot.name should return carrot.
// tests completed
Your code so far
function makeClass() {
"use strict";
/* Alter code below this line */
class Vegetable {
constructor(Vegetable) {
this. Vegetable = Vegetable;
}
}
/* 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 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36.
"use strict";
/* Alter code below this line */
class Vegetable {
constructor(Vegetable){
this.Vegitable = Vegetable;
}
}
/* Alter code above this line */
return Vegetable;
/* Alter code above this line */
return Vegetable;
}
const Vegetable = makeClass();
const carrot = new Vegetable('carrot');
console.log(carrot.name); // => should be 'carrot'
doesn’t work because this is referring to the const carrot that creates a new Vegetable.
So using the code above if you console.log(carrot.Vegetable); logs “carrot”.
You could use any name you want after this, it could be “rasin”. Then change the log to console.log(carrot.rasin) and you will see it logs “carrot”.
I hope this helps you see what is happening in the code. But the tests are looking at console.log(carrot.name); so that is why you have to use this.name.