Tell us what’s happening:
Im given the message
Sorry, your code does not pass. You’re getting there.
You should move the if statement with the condition dataArrIndex === -1 into your addOrUpdateTask function.
but I do have the if statement within the addOrUpdateTask function
Your code so far
<!-- file: index.html -->
/* file: styles.css */
/* file: script.js */
// User Editable Region
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);
} else {
taskData[dataArrIndex] = 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/123.0.0.0 Safari/537.36
Challenge Information:
Learn localStorage by Building a Todo App - Step 30