Learn localStorage by Building a Todo App - Step 36

Tell us what’s happening:

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

} else {

}
};

You should move the dataArrIndex variable into the addOrUpdateTask function. always this message appear what’s wrong in my code please help me

Your code so far

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

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

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

  } else {
    
  }
};

// User Editable Region
/* file: styles.css */

Your browser information:

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

Challenge Information:

Learn localStorage by Building a Todo App - Step 36

You moved the wrong code. The code is located here.

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);
  }
1 Like

oh i got it first we have to create arrow function and then move all the value of dataArrIndex, taskObj and if statement that is in code 50 to 60

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.