Last active
May 30, 2022 17:15
-
-
Save mcsee/ab050467c32205a1b8623352f6bb8dd8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Moviegoer { | |
constructor(age) { | |
this.age = age; | |
} | |
watchXRatedMovie() { | |
if (this.age < 18) | |
throw new Error("You are not allowed to watch this movie"); | |
else | |
this.watchMovie(); | |
} | |
watchMovie() { | |
// .. | |
} | |
} | |
let jane = new Moviegoer(12); | |
jane.watchXRatedMovie(); | |
// Throws exception since Jane is too young to watch the movie |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment