I have an array like this
let names = [
{name:"Haruhiro", alias:["Haru", "Hal"]},
{name:"John", alias:["Jon"]},
{name:"Samantha", alias:["Sam"]},
]
And I need to filter the items of it based on what the user types in.
let output = names.filter((e) => e.name === userInput);
This works well with only names, but I couldn't do it so that it fill check for both name and possible alias, since it can have as many alias as it wants I need to loop throuh it but I'm already in a sort of loop while I'm in the filter. I tried something like
let output = names.filter((e) => e.name === userInput || e.alias.filter((a) => a === userInput));
but it wouldn't work. So There's an array in an array that I'm looping through which I need to loop through