I am new at Javascript and I'm trying to get values of id key, from array that have multi objects inthere.
dynamicList = [
{ id: 1, gorevAdi: "Görev 1" },
{ id: 2, gorevAdi: "Görev 2" },
{ id: 3, gorevAdi: "Görev 3" },
];
Via the for..in loop, I need the id of the objects -like 1,2 or 3- to compare with different values.
I try to do that like that:
function deleteTask(id) {
let deletedId;
for (let index in dynamicList) {
if (dynamicList[index].id == id) {
deletedId = index
}
}
dynamicList.splice(deletedId, 1);
displayTasks()
}
But wehen I did that like this the deleteId value returns undefined.
Icant figur it out why is return undefined and I cant solve that.
I hope I expressed myself well, sorry for my poor english.