As a JavaScript beginner and enthusiast, I'm in need of help. I am encountering an issue with the code snippet provided below:
if (newTask.done === false) {
newTask = doneArray.push({
id: doneArray.length,
description: clickedTask.textContent,
done: false
});
} else {
removeTask = doneArray.splice(newTask.id, 1);
};
I'm trying to determine whether my object has a false or true value in the done key. If a new task has a value of false, I want to push it into my Array. Otherwise, I aim to remove it from the Array. I am struggling with retrieving the value of the ID and using it in the if statement, as well as changing that value within the object to true. I'm unsure if there is a more efficient way to achieve this without scrapping the entire code. You can find the complete code here: codepen.io