I am tying to build a todo list.
The part that fills the list as the user enters something and chooses a date is this:
const renderToDoList = () => {
displayStuffJS.innerHTML = ''
for (let i = 0; i <= toDoList.length - 1; i ++){
let toDoObject = toDoList[i];
let input = toDoObject.input
let date = toDoObject.date
html = `<p style = 'display: inline-block;'>` + input + date +
'<button onclick = "deleteEntry(' + i + ')">Delete</button> + </p>';
displayStuffJS.innerHTML += HTML;
}
}
The array (which has an object inside) is having data put into it here:
const pushToList = () => {
displayStuffJS.innerHTML = "";
toDoList.push([{
input: inputValue.value, // the input where they put their entry
date: getDate.value // the value of the date chosen
}])
inputValue.value ="";
getDate.value = "";
renderToDoList();
}
When I run this code, enter something, choose a date and click add, it shows me that two loops have occurred, filling the array with two objects, the first object being ” for both input and date, the second index in the array is an object with the input and date I select.
enter image description here
it also brings up two delete buttons, but when I click them both they work and delete everything.
pretty stuck now, been on this for an hour and nothing I do works. I have only been programming on and of for a few weeks.
I tried several random things but nothing worked.