Learn localStorage by Building a Todo App - Step 36

Tell us what’s happening:

I’m lost as to what is wrong here and the other forum questions don’t have a clear solution? I’ve cut and paste the contents from my code which I think it’s asking me to do

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 Edg/127.0.0.0

Challenge Information:

Learn localStorage by Building a Todo App - Step 36

you have not followed the instructions in full?

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

could you clarify on the instructions as I don’t think I’m understanding? Here’s my updated code as I think the arrow function should be empty:

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

the instructions seem clear, but if it helps, I will split them up for you so you can read them one at a time.

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

Hopefully you can attempt this and let us know which part you need help understanding.

hi there!

you did not need to write code form scratch within the function. you need to move the existing code you have within your javascript file for that challenge. find dataArrIndex , taskObj obejct and the if statment after it and move that all things to the new fucntion addOrUpdateTask function. you can find your required code from line 50 to 60.

1 Like

Got it now, I was copying the wrong code thank you!

1 Like