I have the following DATA
folders = [
{
id: 1,
title: 'name',
logo: 'logo',
tasks:
[
{
id: 1,
text: 'blaas bla bla',
done: false,
},
{
id: 2,
text: 'bla bla bla',
done: false,
},
]
},
{
id: 2,
title: 'name',
logo: 'logo',
tasks:
[
{
id: 3,
text: 'blasdasda bla bla',
done: true,
},
{
id: 4,
text: 'bla bla bla',
done: false,
},
]
},
{
id: 3,
title: 'name',
logo: 'logo',
tasks:
[
{
id: 5,
text: 'bla bla bla',
done: false,
},
{
id: 6,
text: 'bla bla bla',
done: false,
},
]
}
]
I got folders array that contains data on folders (id name etc) and array of tasks.
I want to get from the user the id of A task and remove that speicific task from the data.
I tried to do the following but it removing all the folder while I want to remove the specific task.
folders.filter( folder => folder.tasks.every( task => task.id != taskId ))
question from:
https://stackoverflow.com/questions/65849816/js-remove-specific-element-in-two-dimensional2d-array 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…