-
Notifications
You must be signed in to change notification settings - Fork 169
resolved tasks - objects #136
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 4 commits
c074972
e4a6539
a21543a
4805cda
7d3835d
51aa204
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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]}` | ||
| ); | ||
| } | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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') { | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
| 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) { | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nie zawsze jest to |
||
| return false; | ||
| } | ||
|
|
||
| if (lang === 'en') { | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Podobnie jak wyżej. |
||
| return translator.en; | ||
| } else { | ||
| return translator.pl; | ||
| } | ||
| } | ||
|
|
||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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' | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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)); | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍