Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 2 additions & 2 deletions 02/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ const calendarJS = {


for(const key in calendarJS) {
if((calendarJS[key]) === null) {
if(calendarJS[key] === null) {
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.

👍

console.log(key, "nie zostało wydane");
} else {
console.log(key, "wydano w terminie", (calendarJS[key]));
console.log(key, "wydano w terminie", calendarJS[key]);
}
}
12 changes: 9 additions & 3 deletions 03/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ books.getTitle = function(isbn, lang) {
}

const title =this[isbn].title;
return lang === 'en' ? title.en : title.pl;
if(typeof title[lang] !== 'undefined') {
return title[lang];
}
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.

👍

}

books.getTranslator = function(isbn, lang) {
Expand All @@ -56,8 +58,12 @@ books.getTranslator = function(isbn, lang) {
}

const translator = this[isbn].translator;
const result = translator[lang];
return result === null ? false : result;

if(typeof translator[lang] === 'undefined') {
return false;
}

return translator[lang] === null ? false : translator[lang];
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.

Można połączyć oba rozwiązania (moje i Twoje) tj.

const result = translator[lang];
if(result === 'undefined') {
    return false;
}

return result === null ? false : result;

Może być bezpieczniejsze bo nie zrobimy nigdzie literówki powtarzając translator[lang]

}


Expand Down