const tasks = [ { id: 1, completed: false, title: "Buy groceries for the week", description: "Pick up vegetables, fruits, milk, eggs, and bread from the supermarket.", dueDate: "14/03/2026", dateCreated: new Date(Date.now()).toLocaleDateString("en-AU") }, { id: 2, completed: false, title: "Clean the apartment", description: "Vacuum the floors, wipe kitchen surfaces, and take out the trash.", dueDate: "16/03/2026", dateCreated: new Date(Date.now()).toLocaleDateString("en-AU") }, { id: 3, completed: false, title: "Call the dentist for appointment", description: "Book a routine checkup and confirm available time slots for next week.", dueDate: "17/03/2026", dateCreated: new Date(Date.now()).toLocaleDateString("en-AU") }, { id: 4, completed: true, title: "Do laundry and fold clothes", description: "Wash dark and light loads separately, then fold and organize clean clothes.", dueDate: "21/03/2026", dateCreated: new Date(Date.now()).toLocaleDateString("en-AU") } ]; // GLOBALS const $taskForm = document.getElementById('taskForm'); const $toDoList = document.getElementById('toDoList'); const $completedList = document.getElementById('completedList'); // EVENT LISTENERS window.addEventListener("DOMContentLoaded", () => { displayTasks(); }) // DISPLAY TASKS function displayTasks(){ function formatTask(task){ const li = document.createElement("li"); li.classList.add('card','p-3','mt-2'); const done = task.completed ? "text-decoration-line-through opacity-50" : ""; li.innerHTML = `

${task.title}

${task.description}

Due: ${task.dueDate}

${ task.completed ? `` : ` ` }

Created on: ${task.dateCreated}

`; return li; } $toDoList.innerHTML = ""; $completedList.innerHTML = ""; tasks.forEach(task => { const formattedTask = formatTask(task); task.completed ? $completedList.appendChild(formattedTask) : $toDoList.appendChild(formattedTask) }) }