-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathdailyWords.js
More file actions
26 lines (21 loc) · 796 Bytes
/
dailyWords.js
File metadata and controls
26 lines (21 loc) · 796 Bytes
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
// Date of start, gonna just say October 4, 2023 for now
const startDate = new Date("October 4, 2023");
function getCurrentDate() {
let now = new Date();
let localDate = new Date(now.getFullYear(), now.getMonth(), now.getDate());
document.getElementById("today").textContent = localDate.toLocaleDateString();
return localDate;
}
function getDayDifference() {
let currentDate = getCurrentDate();
let adjustedStartDate = new Date(
startDate.getFullYear(),
startDate.getMonth(),
startDate.getDate()
);
let timeDifference = currentDate - adjustedStartDate;
return Math.floor(timeDifference / (1000 * 60 * 60 * 24));
}
let dayDifference = getDayDifference();
let wordsForTheDay = wordList[dayDifference % wordList.length];
let puzzleNumber = (dayDifference % wordList.length) + 1;