This is my JSON file:
layers :[
{
key: "1",
title: "Computer Science",
expanded: false,
subLayer: [
{
key: "a",
title: "Programming Language",
expanded: false,
subLayer: [
{
key: "a.1",
title: "HTML",
expanded: false,
subLayer: [],
},
{
key: "a.2",
title: "CSS",
expanded: false,
subLayer: [],
},
],
},
],
},
]
Images:
My question is: When I search Programming Language and Computer Science it appears but if you search for parts in subLayer elements such as HTML and CSS it doesn't appear or can't, why is that? And what needs to be improved from my coding? If I'm writing my code:
const filteredData = data.layers.filter((el) => {
if (props.input === '') {
return el
}
return el.title.toLowerCase().includes(props.input) || el.subLayer.findIndex(x => x.title.toLowerCase().includes(props.input)) >= 0
})
