Skip to content

Commit

Permalink
update SkillfactoryCoding#10 rewrite randomDate
Browse files Browse the repository at this point in the history
  • Loading branch information
cookieru committed Feb 5, 2024
1 parent 78e7020 commit e52ad1b
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions bjs/10_function_object/personGenerator.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,22 @@ const personGenerator = {
}
}`,

months:
{
1: "января",
2: "февраля",
3: "марта",
4: "апреля",
5: "мая",
6: "июня",
7: "июля",
8: "августа",
9: "сентября",
10: "октября",
11: "ноября",
12: "декабря"
},

GENDER_MALE: 'Мужчина',
GENDER_FEMALE: 'Женщина',

Expand Down Expand Up @@ -176,13 +192,13 @@ const personGenerator = {

randomGender: function() {

return this.randomIntNumber() === 1 ? this.GENDER_MALE : this.GENDER_FEMALE;
return this.randomIntNumber() ? this.GENDER_MALE : this.GENDER_FEMALE;

},

randomDate: function() {

const year = this.randomIntNumber(110, 70) + 1900;
const year = this.randomIntNumber(104, 70) + 1900;
const month = this.randomIntNumber(12, 1);

const isEven = month % 2 === 0;
Expand All @@ -205,7 +221,11 @@ const personGenerator = {

const day = this.randomIntNumber(maxDay, 1);

return `${day}.${month}.${year}`;


let textMonth = this.months[month]

return `${day} ${textMonth} ${year} г.`;
},


Expand Down

0 comments on commit e52ad1b

Please sign in to comment.