Search⌘ K
AI Features

Challenge: Counting Animals

Explore how to apply object-oriented programming principles in JavaScript through a practical challenge focused on counting animals. This lesson helps you troubleshoot, modify code, and reinforce your understanding of OOP by solving a real coding problem with guided practice.

We'll cover the following...

Problem statement #

Study the code below and then run it.

Javascript (babel-node)
class Animal {
constructor() {
this.count = 0;
}
static increaseCount() {
this.count += 1;
}
static getCount() {
return this.count;
}
}
function test(){
Animal.increaseCount();
console.log(Animal.getCount());
}
test()

Your task ...