// Get the current date
let today = new Date();
// Get the year of the current date
let christmasYear = today.getFullYear();
// Check if the current date is already past December 25th
if (today.getMonth() === 11 && today.getDate() > 25) {
// If so, set Christmas for the next year
christmasYear = christmasYear + 1;
}
// Get the date of the next Christmas
let christmasDate = new Date(christmasYear, 11, 25); // Month 11 is December (0-indexed)
// Get the number of milliseconds in one day
const dayMilliseconds = 1000 * 60 * 60 * 24;
// Calculate the remaining amount of days
let remainingDays = Math.ceil((christmasDate.getTime() - today.getTime()) / dayMilliseconds);
// Display the result (e.g., in the console or on a webpage)
console.log(`${remainingDays} days left until Christmas!`);
// Or, to display on an HTML page:
// document.getElementById("countdown").innerText = `${remainingDays} days left until Christmas!`;