Strings Hw

1 min read

Code Runner Challenge

Homework Challenge - Create a class and make 2 different methods.

View IPYNB Source
%%js
// CODE_RUNNER: Homework Challenge - Create a class and make 2 different methods.

// class
class Puppy {
    constructor(name, breed) {
        this.name = name;
        this.breed = breed;
    }
    
    // method #1
    bark() {
        return `${this.name} says Woof`;
    }

    // method #2
    fetch() {
        return `${this.name} is fetching the ball`;
    }
}

const myPuppy = new Puppy('Max', 'Golden Retriever');

console.log(myPuppy.bark());

console.log(myPuppy.fetch());
Lines: 1 Characters: 0
Output
Click "Run" in code control panel to see output ...

Course Timeline