I am getting an error during the page load I think true code but console declare warning forEach() is not a function Help me please if you have time. Thank you for the help.
function duty() {
let tasks;
if (localStorage.getItem("tasks") === null) {
tasks = [];
} else {
tasks = JSON.parse(localStorage.getItem("tasks"));
}
tasks.forEach(function (item) {
const li = document.createElement("li");
li.className = "collection-item";
li.appendChild(document.createTextNode(item));
const link = document.createElement("a");
link.className = "delete-item secondary-content";
link.innerHTML = "<i class='fas fa-trash'></i>";
li.appendChild(link);
taskList.appendChild(li);
});
}