Learn localStorage by Building a Todo App - Step 44

Tell us what’s happening:

Currently stuck on this step is there something i might be missing please help.

Your code so far

<!-- file: index.html -->

/* file: styles.css */

/* file: script.js */
// User Editable Region

const deleteTask = (buttonEl) => {
  const dataArrIndex = taskData.findIndex(
    (item) => item.id === buttonEl.parentElement.id
    buttonEl.parentElement.remove();
    taskData.splice(dataArrIndex, 1)
  );
  
}

// User Editable Region

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36

Challenge Information:

Learn localStorage by Building a Todo App - Step 44

Hi @daylightattack

Since you have more than one expression, you need to wrap them in curly braces.

Happy coding

The whole code is wrapped in curly braces can you provide more clear instructions?

You added the two lines of code inside the findIndex callback. They should be after the findIndex code.

What @Teller means is that an arrow function should have curly braces around the code to be executed if there is more than one expression within it. An implicit return (no curly braces) works if there is one expression to be returned. If you make the change suggested it will pass.

@lasjorg suggested a different way, which also works.

It is a bug that you can pass the challenge with the code inside the callback. You do not have access to dataArrIndex inside the callback, and it is used by the splice call.

It’s just because it is using a regex for the test.

https://github.com/freeCodeCamp/freeCodeCamp/blob/main/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faf874364ec308f875f636.md