Learn localStorage by Building a Todo App - Step 30

Tell us what’s happening:

I get the following message, which is incorrect. taskObj is in the function, the tests fails are wrong. I have everything in the order the instructions mentions them. Side note: I have wasted half my time with picky formatting expectations not being mentioned in the fail responses, it’s incredibly tiring. I bet this is another formatting issue, but I don’t see it.

You should move the `taskObj` object into the `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);
    }
};

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) 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

3 Likes

You are correct, test is too strict here. If you add comma at the end of following line, everything passes:

description: descriptionInput.value
2 Likes

Thanks. I knew there was a formatting problem somewhere.

1 Like

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

}

1 Like

Can confirm this is the exact format the question accepts.
I had to delete a semicolon for the submission to be accepted. " ; "
(second to last line)

the comma at the end of the description line was already present as well.

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,                   // comma was already present
  };
   if (dataArrIndex === -1) {
    taskData.unshift(taskObj);
  }              //  i had to remove the ; on this line.
}

i’ve made this comment in case the previous issue was fixed and a new one was created. it happens

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