Solution Review: ES6 Classes

This lesson will explain the solution to the problem in the previous lesson.

We'll cover the following...

Solution #

Press + to interact
class Cat {
constructor (name) {
this.name = name
}
meow () {
console.log(this.name + ' says meow')
}
}
let catty = new Cat('catty')
catty.meow()

Explanation #

This challenge tests your knowledge of OOP in the ES6 version of JavaScript.

The following code was provided to you:

Press + to interact
function Cat (name) {
this.name = name
}
Cat.meow = function () {
console.log(this.name + ' says meow')
}
let catty = new Cat('catty')
catty.meow()

Let’s figure out what the issue in this code was. From ...