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
14 changes: 7 additions & 7 deletions 03/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ books.getTitle = function(isbn, lang) {
}


if (lang === 'en') {
return title.en;
if (title[lang]) {
return title[lang];
} else {
return title.pl;
return 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.

👍

}

}
Expand All @@ -66,14 +66,14 @@ books.getTranslator = function(isbn, lang) {
return null;
}

if (translator[lang] === null) {
if (translator[lang] === null || translator[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.

Tutaj bym uważał. W zadaniu jest jasno napisane, że null więc tylko bym sprawdzał tą wartość.
undefined to co innego - wtedy ma być zwracane null (ostatni warunek, który masz)

return false;
}

if (lang === 'en') {
return translator.en;
if (translator[lang]) {
return translator[lang];
} else {
return translator.pl;
return null;
}
}

Expand Down
11 changes: 7 additions & 4 deletions 04/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ const user = {
firstName: 'Adam',
lastName: 'Nowak',
born: {
day: '14',
month: '04',
day: '04',
month: '12',
year: '1985'
}
}
Expand All @@ -20,12 +20,15 @@ function checkBirthday(user){
const birthdayMonth = parseInt(userBirthday.month);

if (birthdayDay == currentDay && birthdayMonth == currentMonth) {
return 'Wszystkiego najlepszego z okazji dzisiejszych urodzin!';
return true;
}
else {
return 'Dzis nie masz urodzin'
return false;
}

}
if (checkBirthday(user)){
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('Wszystkiego najlepszego z okazji urodzin!');
}

console.log(checkBirthday(user));