Skip to content

Instantly share code, notes, and snippets.

@raikusy
Created April 8, 2019 17:25
Show Gist options
  • Save raikusy/5330a16801faf02e1f17f4f9e407070d to your computer and use it in GitHub Desktop.
Save raikusy/5330a16801faf02e1f17f4f9e407070d to your computer and use it in GitHub Desktop.
class Book {
constructor(author, isbn, genre) {
this.author = author;
this.isbn = isbn;
this.genre = genre;
}
getDescription() {
return this.author+' '+this.isbn+' '+this.genre;
}
}
class Adventure extends Book {
constructor(author, isbn, genre, price) {
super(author, isbn, genre);
this.price = price;
}
getDescription() {
return super.getDescription() + ' ' + this.price;
}
}
let book = new Book('Fundamentals of Javascript', 'BA1234UX09', 'Herbert Shin');
console.log(book.author);
console.log(book.getDescription());
let adventure = new Adventure('Around the world in 80 days', 'YT46582BNH', 'Jules Verne', 7.99);
console.log(adventure.getDescription());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment