Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions 03/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ books.getAuthor = function (isbn) {
};

books.getTitle = function (isbn, lang) {
if (typeof this[isbn] === 'undefinej') {
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

👍

return null;
}

if (typeof this[isbn]['title'][lang] === 'undefined') {
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Warto sprawdzić jeszcze poprzedni element tj. "isbin" jeśli ten element nie istnieje to kod rzuci błędem i przestanie działać reszta. Obecne rozwiązanie sprawdza tylko czy lang istnieje. Dlatego trzeba najpierw wykonać sprawdzenie:

if(typeof this[isbn] !== 'undefined') { ... }

return null;
}
Expand All @@ -55,6 +59,10 @@ books.getTitle = function (isbn, lang) {
};

books.getTranslator = function (isbn, lang) {
if (typeof this[isbn] === 'undefinej') {
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

👍

return null;
}

if (typeof this[isbn]['translator'][lang] === 'undefined') {
return null;
}
Expand Down
2 changes: 1 addition & 1 deletion 04/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const user = {
firstName: 'Adam',
lastName: 'Nowak',
born: {
day: '05',
day: '06',
month: '04',
year: '2025',
},
Expand Down