Learn localStorage by Building a Todo App - Step 30

Tell us what’s happening:

Hi, I am stuck here. I dont know which part is wrong, already followed the instructions. Can anyone help to check which part I wrongly do?

Instructions:
Use arrow syntax to create an addOrUpdateTask function. Then move the dataArrIndex variable, the taskObj object, and the if statement into the addOrUpdateTask function.

Error thrown:
You should move the if statement with the condition dataArrIndex === 1 into your addOrUpdateTask function

Your code so far

const addOrUpdateTask = () => {
  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);
  }

  taskData.forEach(({ id, title, date, description }) => {
    tasksContainer.innerHTML += `
      <div class="task" id="${id}">
        <p><strong>Title:</strong> ${title}</p>
        <p><strong>Date:</strong> ${date}</p>
        <p><strong>Description:</strong> ${description}</p>
        <button type="button" class="btn">Edit</button>
        <button type="button" class="btn">Delete</button>
      </div>
    `;
  });

  reset();
};

WARNING

The challenge seed code and/or your solution exceeded the maximum length we can port over from the challenge.

You will need to take an additional step here so the code you wrote presents in an easy to read format.

Please copy/paste all the editor code showing in the challenge from where you just linked.

Replace these two sentences with your copied code.
Please leave the ``` line above and the ``` line below,
because they allow your code to properly format in the post.

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36

Challenge Information:

Learn localStorage by Building a Todo App - Step 30

Welcome to our community!

You have deleted some code lines from the challenge which shouldn’t be erased. Check all again.
After the if statement, you must close the addOrUpdateTask function with the right curly brace }.

Sorry but i still don’t get it :frowning: i didn’t erase any code lines from the challenges and already close the function with the right curly brace

Could this error by a mistake in the creation of the exercise. I also get " You should move the if statement with the condition dataArrIndex === 1 into your addOrUpdateTask function." but I can only pass when i use -1 instead of 1.