Mark As Completed Discussion

Try this exercise. Click the correct answer from the options.

Given the following code, what output will the line console.log of code print?

JAVASCRIPT
1class Book {
2	constructor(title, author, ISBN, numberOfPages, publicationYear) {
3		this.title = title;
4		this.author = author;
5		this.ISBN = ISBN;
6		this.numberOfPages = numberOfPages;
7		this.publicationYear = publicationYear;
8	}
9	get title() {
10		return this._title
11	}
12	set title(value) {
13		this._title = value
14	}
15}
16let myBook = new Book('Life of Pi', 'Yann Martel', 9780156027328, 352, 2001)
17let myBook2 = new Book('Life of Sky', 'Yann Martel', 9780156027328, 352, 2001)
18myBook2.title = myBook.title
19console.log(myBook.title)

Click the option that best answers the question.

  • Life of Pi
  • Life of Sky
  • No output
  • Error