Skip to content

Commit

Permalink
added helper fuctions for cookie
Browse files Browse the repository at this point in the history
  • Loading branch information
I-AM-T3X committed Jun 16, 2024
1 parent f0feaa2 commit 66774a8
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions script.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,25 @@ function decodeWords(encodedWords) {

const words = decodeWords(encodedWords);

// Helper functions to handle cookies
function setCookie(name, value, days) {
const date = new Date();
date.setTime(date.getTime() + (days*24*60*60*1000));
const expires = "expires=" + date.toUTCString();
document.cookie = name + "=" + value + ";" + expires + ";path=/";
}

function getCookie(name) {
const nameEQ = name + "=";
const ca = document.cookie.split(';');
for(let i = 0; i < ca.length; i++) {
let c = ca[i];
while (c.charAt(0) === ' ') c = c.substring(1);
if (c.indexOf(nameEQ) === 0) return c.substring(nameEQ.length, c.length);
}
return null;
}

function getWordOfTheDay() {
const startDate = new Date("2024-01-01"); // Starting date of your word list
const today = new Date();
Expand Down

0 comments on commit 66774a8

Please sign in to comment.