-
Notifications
You must be signed in to change notification settings - Fork 0
/
birthday_checker.js
75 lines (58 loc) · 2.06 KB
/
birthday_checker.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
const readline = require('readline');
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});
rl.question('What is your name: ', function(name) {
rl.question('What is your birth month: ', function(birthMonth) {
rl.question('What is your birth day: ', function(birthDay) {
rl.question('What is your birth year: ', function(birthYear){
let today = new Date();
let currentMonth = today.getMonth() + 1;
let currentDay = today.getDate();
if (currentMonth == birthMonth && currentDay == birthDay) {
console.log('Happy Birthday!')
} else {
console.log(`Hi ${name}. Your birthday is ${birthMonth}-${birthDay}-${birthYear}`)
}
rl.close();
});
})
});
});
rl.on("close", function() {
// console.log("\nBYE BYE !!!");
process.exit(0);
});
// const name = "Bill"
// const month = 3;
// const date = 18;
// const year = 1962;
// let today = new Date();
// let isBirthDay = new Date(year, month -1, date);
// const getUserBirthDay = function() {
// if (mane = 'Bill' && (today.getMonth() + 1) == isBirthDay.getMonth() + 1 && today.getDate() == isBirthDay.getDate()) {
// console.log('Happy Birthday!');
// } else {
// console.log(`Hi ${name}. Your birthday is ${isBirthDay.getMonth() + 1 }-${isBirthDay.getDate()}-${isBirthDay.getFullYear()}.`);
// }
// };
// console.log(getUserBirthDay())
// let name = 'Mike Jones';
// let month = 2;
// let day = 12;
// let year = 1945;
// let currentMonth = (new Date().getMonth() + 1);
// let currentDay = new Date().getDate();
// let bDay = new Date(year, month, day);
// const getUserBirthDay = function() {
// birthMonth = bDay.getMonth();
// birthDay = bDay.getDate();
// birthYear = bDay.getFullYear()
// if (name == ' ' && currentMonth == birthMonth && currentDay == birthDay) {
// return 'Happy Birthday!';
// } else {
// return `Hi ${name}. Your birthday is ${birthMonth}-${birthDay}-${birthYear}.`;
// }
// };
// console.log(getUserBirthDay())