Learn localStorage by Building a Todo App - Step 16

Tell us what’s happening:

Hey Guys, I am stuck on this step. It should be a simple object destruction step, but regardless of what I try, I can not get through it. Someone got an idea, what I am missing?

The task is:
Now that you have saved the task in the taskData array, you should display the task on the page by looping through it.

Use forEach() on taskData, then destructure id, title, date, description as the parameters. Don’t return anything yet.

Your code so far

taskForm.addEventListener(“submit”, (e) => {
e.preventDefault();

const dataArrIndex = taskData.findIndex((item) => item.id === currentTask.id);
const taskObj = {
id: ${titleInput.value.toLowerCase().split(" ").join("-")}-${Date.now()},
title: titleInput.value,
date: dateInput.value,
description: descriptionInput.value,
};

if (dataArrIndex === -1) {
taskData.unshift(taskObj);
}

//New code should get written here //

});

Here is what I think is the most plausible. Tried like 10 others versions aswell.

taskData.forEach((id, title, date, description) => {})

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:109.0) Gecko/20100101 Firefox/115.0

Challenge Information:

Learn localStorage by Building a Todo App - Step 16

1 Like

Put your parameter inside curly brackets, look like this ({}).

4 Likes

Ohhh, thank you so much!

1 Like

You’re welcome Reggi.

This works but why ?

I didn’t really get it aswell. I am not sure, but maybe it would work without the curly brackets outside of “freecodecamp” as well. But since they want to underline the “object destruction” in this step, we are supposed to use the curly brackets.

I could be wrong on this one though.

2 Likes

was facing the same issue but when i read the solution on this page, it hit me, the instructions clearly state that “Use forEach() on taskData , then destructure id , title , date , description as the parameters.” Emphasis on “as the parameters” and parameters are in round brackets (). Maybe that’s why the destructuring works within the round brackets. or maybe i’m wrong XD