From a5800a2b219025de66a6eebb383d4e732a75c8aa Mon Sep 17 00:00:00 2001 From: WhyKorp <117651228+whykorp@users.noreply.github.com> Date: Mon, 11 Mar 2024 06:31:34 +0100 Subject: [PATCH] Update scripttodo.js --- ruty/js/scripttodo.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/ruty/js/scripttodo.js b/ruty/js/scripttodo.js index 61e91f2..2cded72 100644 --- a/ruty/js/scripttodo.js +++ b/ruty/js/scripttodo.js @@ -59,4 +59,17 @@ document.addEventListener("DOMContentLoaded", function() { newCategoryInput.value = ""; } }); + + // Function to load existing todos from localStorage + function loadTodos() { + const savedTodos = JSON.parse(localStorage.getItem("todos")) || []; + savedTodos.forEach(todo => { + const todoItem = document.createElement("li"); + todoItem.textContent = todo; + todoList.appendChild(todoItem); + }); + } + + // Call loadTodos on page load + loadTodos(); });