-
Notifications
You must be signed in to change notification settings - Fork 6
/
student.js
33 lines (31 loc) · 888 Bytes
/
student.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
class Student {
constructor(name, surname, dob) {
this.name = name;
this.surname = surname;
this.dob = dob;
}
isBirthday() {
const dob = this.dob;
const dateArray = dob.split('/')
const correctFormat = dateArray.map(n => n).reverse();
const newString = correctFormat.join();
const dateUtc = new Date(newString);
const today = new Date()
const twoDates = (dateUtc + today);
let todayStr = '';
let birthdayStr = '';
for (let i = 4; i < 10; i++) {
const element = twoDates[i];
todayStr += element;
}
for (let i = 71; i < 77; i++) {
const element = twoDates[i];
birthdayStr += element;
}
if (birthdayStr === todayStr) {
return true
} else {
return false
}
}
}