AI

Classes are blueprints for creating objects. They encapsulate data and behavior.

Your Task:

  • Define a class named Animal
  • Add a constructor that takes a name and stores it as property
  • Add a method speak() that returns "[name] makes a noise."
  • Create an instance dog with name "Rex"
  • Call dog.speak() and store it in sound
TypeScript Solution
Loading...

Submit your code to see test results