const word = ["house", "mango", "window", "watermelon"]
const component = ["us", "man", "ous", "go", "water", "melon", "win", "dow"]
const output = [{
"word": "house",
"component": ["us", "ous"]
}, {
"word": "mango",
"component": ["man", "go"]
}, {
"word": "window",
"component": ["win", "dow"]
}, {
"word": "watermelon",
"component": ["water", "melon"]
}, ]
const answer = [];
for (let i = 0; i <= word.length - 1; i++) {
answer.push(word[i]);
}
console.log(answer, output);
so I was practicing a tutorial where I was given two arrays and asked to group them together -- if a component includes a word I should group them together but I have been unable to move past the for loop and run an if check. Please can anybody help?