score:8

Accepted answer
let articles = [{title: 'title 1', tags :["JavaScript", "ES6"], category: "JavaScript"},{title: 'title 2', tags :["React", "TypeScript"], category: "React"},{title: 'title 3', tags :["JavaScript", "Inheritance", "Prototype"], category: "JavaScript"}]
 
let search = 'java';
let result = articles.filter(({tags}) => {
  return tags.some(e => e.toLowerCase().includes(search.toLowerCase()))
})

console.log(result)

score:0

    // the filter

const nodes = $.grep(data, function f(node) {
    const nodeIncludesValue = node.name.toLowerCase().includes(value);

    if (node.children && node.children.length > 0) {
        return $.grep(node.children, f) || nodeIncludesValue;
    }   

    return nodeIncludesValue;
});



// No unnecessary elements

createTree(nodes, container)
{
    const list = document.createElement('ul');

    nodes.forEach((node) => {
        const listItem = document.createElement('li');
        listItem.textContent = node.name;
        list.appendChild(listItem);

        if (node.children && node.children.length > 0) {
            const childList = document.createElement('li');
            this.createTree(node.children, childList);
            list.appendChild(childList);
        }
    });

    container.appendChild(list);
}

score:2

let articles = [{title: 'title 1', tags :["JavaScript", "ES6"], category: "JavaScript"},{title: 'title 2', tags :["React", "TypeScript"], category: "React"},{title: 'title 3', tags :["JavaScript", "Inheritance", "Prototype"], category: "JavaScript"}]

let search = "ES";
let result = articles.filter(((data)=>data.tags.some(v => v.includes(search))))

console.log(result)

Related Query

More Query from same tag