What would be the correct way to solve this problem using Javascript?
You are provided with the following information:
● January 1, 1900 was a Monday.
● Thirty days have September, April, June and November.
● February is twenty-eight (and in leap years, twenty-nine).
● The rest have thirty-one.
Note: A leap year occurs in any year divisible by 4, but not in a century unless it is divisible by 400.
How many Sundays fell on the first day of the month during the 20th century (January 1, 1901 to December 31, 2000)?
Greetings friend, your problem is really simple. I won't give you much code because I'm on the phone and it's complicated, but I'll try to make you understand me. You need a for loop and three switches. You also need to know how many days there are from the start date to the end date. end, January 1, 1901 to December 31, 2000 in this case, which is the closest leap year to the start date (in the example I will assume that the leap year is the same start date) some if conditionals and variables correct e.g.
The same principle you apply to find the leap year (if(year==4){leap=si; year=0;} and the number of the month only applies a little logic and with an if (dayOfMonth ==1 && dayWeek= ='Sunday'){variableWhatISeek++} and everything inside the for loop. Good luck with what you do
This is my attempt, the first time I do it, I hope it works for you: