Skip to content

homework nine#10

Open
ChrissyDev wants to merge 2 commits into
mainfrom
homework-nine
Open

homework nine#10
ChrissyDev wants to merge 2 commits into
mainfrom
homework-nine

Conversation

@ChrissyDev

Copy link
Copy Markdown
Owner

No description provided.

Comment thread oop_basics/book.js
Comment on lines +12 to +13
set title(newTitle) {
this._title = newTitle;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add validation rules to each set method

Comment thread oop_basics/book.js
Comment on lines +28 to +35
set releaseYear(newYear) {
if (typeof newYear === 'number') {
this._releaseYear = newYear;
} else {
console.error('Invalid input. Year must be a number.');
}
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use "Return Early" pattern

Comment thread oop_basics/eBook.js
}

set fileFormat(newFormat) {
this._fileFormat = newFormat;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add validation rules

Comment thread oop_basics/book.js
}

set title(newTitle) {
if (typeof newTitle !== 'string' || newTitle.trim() === '') {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if (typeof newTitle !== 'string' || !newTitle.trim().length)
would be more convenient

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants