A website to find the day of the week for any given date.
Specification | Input | Output |
---|---|---|
Take number input from user | select: 8 / 10 / 1998 | Date {Month: 8, Day: 10, Year: 1998} |
Return date to user | Date {Month: 8, Day: 10, Year: 1998} | Show 8/10/1998 |
Count number of days in current month | Day: 10 | const daysNumb = 10 |
Count number of days from past months in the year | Month: 8 | const monthsNum = 181 |
Count number of days from past years | Year: 1998 | let yearsNum = 728905 |
Add number of days to allow for leap years | let yearsNum = 728905 | let yearsNum = 729404 |
Add number of days all together | yearsNum + monthsNUm + daysNum | const daysSum = 729595 |
Divide days by 7 to get day of the week number | daysSum % 7 | const finalDay = 6 |
Check what day of the week the day is | if (finalDay == 6)... | const dayOfWeek = Saturday |
Return day to user | dayOfWeek = Saturday | show Saturday |