Skip to content
Open
Show file tree
Hide file tree
Changes from 4 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 01/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
const user = {
firstName: 'Janusz',
lastName: 'Kowalski',
sex: 'male',
age: 48,
}

console.log(user.firstName, user.lastName, user.sex, user.age);
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.

👍

8 changes: 7 additions & 1 deletion 02/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,10 @@ const calendarJS = {
'ES7': '2016-06',
'ES8': '2017-06',
'ES9': '2018-06',
}
}

for (const date in calendarJS){
console.log(
calendarJS[date] === null ? `${date} nie zostało wydane` : `${date} wydano w roku ${calendarJS[date]}`
);
}
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.

👍

28 changes: 28 additions & 0 deletions 03/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,38 @@ books.getAuthor = function(isbn) {

books.getTitle = function(isbn, lang) {

const title = this[isbn].title;

if (!title) {
return null;
}


if (lang === 'en') {
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.

Zdecydowanie mało elastyczne. Co jeśli pojawią się inne języki? Lepsza opcja to if(title[lang]) - jeśli występuje tytuł w danym języki to... np. zwróć :)

return title.en;
} else {
return title.pl;
}

}

books.getTranslator = function(isbn, lang) {

const translator = this[isbn].translator;

if (!translator) {
return null;
}

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

nie zawsze jest to null domyślnie (bez ustawienia) jest to undefined

return false;
}

if (lang === 'en') {
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.

Podobnie jak wyżej.

return translator.en;
} else {
return translator.pl;
}
}


Expand Down
24 changes: 23 additions & 1 deletion 04/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,26 @@ const user = {
month: '04',
year: '1985'
}
}
}

const currentDate = new Date();
const currentDay = currentDate.getDate();
const currentMonth = currentDate.getMonth() + 1;


function checkBirthday(user){

const userBirthday = user.born;
const birthdayDay = parseInt(userBirthday.day);
const birthdayMonth = parseInt(userBirthday.month);

if (birthdayDay == currentDay && birthdayMonth == currentMonth) {
return 'Wszystkiego najlepszego z okazji dzisiejszych urodzin!';
}
else {
return 'Dzis nie masz urodzin'
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.

Lepiej zwrócić true/fasle, a potem zwracać komunikat, bo może być on np. różny - co innego napiszesz babci, co innego dziecku, a jeszcze inaczej partnerce ;)

PS. W szczególności, że nazwa funkcji wskazuje sprawdzenie tak/nie - zamiast konkretnego komunikatu. Oczywiście się czepiam, ale w przyszłości może to być pomocne ;P

}

}

console.log(checkBirthday(user));