Learn localStorage by Building a Todo App - Step 36

Tell us what’s happening:

The task is

You can enhance code readability and maintainability by refactoring the submit event listener into two separate functions. The first function can be used to add the input values to taskData, while the second function can be responsible for adding the tasks to the DOM.

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

and I dont know what mistake I am making

Your code so far

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

/* file: styles.css */

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

const addOrUpdateTask = ()=>{ 
  if(dataArrIndex === 1){
    taskData.unshift(taskObj)
  }
}



// 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/127.0.0.0 Safari/537.36

Challenge Information:

Learn localStorage by Building a Todo App - Step 36

Step 36 also asks you to move the variable dataArrIndex, the object taskObject into the function you created. You haven’t done this. You have also changed a bit of your if statement. I suggest you reset the step and try again.