Tell us what’s happening:
The way the question is presented, wouldn’t this be how the solution should be stated?
Your code so far
<!-- file: index.html -->
/* file: styles.css */
/* file: script.js */
// User Editable Region
const addOrUpdateTask () => {
dataArrIndex(),
taskObj(),
if(),
};
// 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/131.0.0.0 Safari/537.36
Challenge Information:
Learn localStorage by Building a Todo App - Step 36
Teller
December 27, 2024, 8:51pm
2
Hi @booleanmethod9
Those are not variable declarations or the if
statement you coded earlier.
Happy coding
What of this then…
const addOrUpdateTask () => {
dataArrIndex();
taskObj();
if(formInputsContainValues);
};
Teller
December 27, 2024, 10:18pm
4
The arrow function is malformed. It it missing the equals sign between the function name and the round braces.
Once you fix that, this is the error message:
You should move the dataArrIndex
variable into the addOrUpdateTask
function.
For this step you need to cut and paste code.
Happy coding
It happened exactly just as you said indeed!
This is the code that I am currently working with…
It says --You should move the if
statement with the condition dataArrIndex === -1
into your addOrUpdateTask
function.–
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);
};
};
Remove that last semicolon after if statement’s body closing bracket }
But why, isn’t there supposed to be a semicolon there?
After if
statement sometimes we use else
statement. And when we use else
statement, there should not we have a semicolon after if block.