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: 'Sandra',
lastName: 'Mstowska',
sex: 'woman',
age: 26,
}

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.

👍

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


for(const key in calendarJS) {
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.

Dodatkowe nawiasy okrągłe nie są potrzebne, wystarczy: if(calendarJS[key] === null) {

console.log(key, "nie zostało wydane");
} else {
console.log(key, "wydano w terminie", (calendarJS[key]));
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 podobnie

}
}
12 changes: 12 additions & 0 deletions 03/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,26 @@ books.getAuthor = function(isbn) {
}

books.getTitle = function(isbn, lang) {
if(typeof this[isbn] === 'undefined') {
return null;
}

const title =this[isbn].title;
return lang === 'en' ? title.en : title.pl;
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.

Co jeśli dodamy 10 języków? Będziemy dodawać 10 if-ów? Lepszym rozwiązaniem jest:

if(typeof title[lang] !== 'undefined') { // jeśli istnieje taki język w title
    return title[lang]; // to zwróć jego wartość
}

}

books.getTranslator = function(isbn, lang) {
if(typeof this[isbn] === 'undefined') {
return null;
}

const translator = this[isbn].translator;
const result = 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.

Tutaj jest lepiej, ale warto sprawdzić czy faktycznie istnieje podany język. Co się stanie jak wpiszemy np. ES zamiast EN?

return result === null ? false : result;
}



console.log( books.getAuthor('978-83-7278-000-3') ); // J.K. Rowling
console.log( books.getAuthor('000-00-0000-000-0') ); // null
console.log( books.getTitle('978-83-7278-000-3', 'pl') ); // Harry Potter i Kamień Filozoficzny
Expand Down
20 changes: 17 additions & 3 deletions 04/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,22 @@ const user = {
firstName: 'Adam',
lastName: 'Nowak',
born: {
day: '14',
month: '04',
day: '18',
month: '08',
year: '1985'
}
}
}

function happyBday(user) {
const today = new Date();
const day = today.getDate();
const month = today.getMonth() + 1;

if (day == user.born.day && month == user.born.month) {
return "Today is your birthday!";
} else {
return "Today is not your birthday :c";
}
}

console.log(happyBday(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.

👍