+ 2
Line 2, constructors in JavaScript are not like constructors in languages like Java or C# or C++ in the sense that to define a constructor you don't use the class name. Instead, you need to use the keyword `constructor`, like so constructor(name) { this.name = name } Then on line 12, you are specifying the type name of `obj`. This is not valid in JavaScript. Use the keyword `var` or `let` or `const`. let obj = new Person("Malick") obj.eat("yassa") See the module on classes in SoloLearn https://www.sololearn.com/learning/2979/
28th Jan 2021, 7:33 AM
XXX
XXX - avatar