Estoy tratando de limpiar una matriz ( secondArray ) eliminando los elementos que también están incluidos en otra matriz ( secondRegex ). Este es uno de mis últimos intentos, pero no funciona :'( El resultado que obtengo es: 0[]. ¿Por qué???????
const secondRegex = ['i', 'a', 'about', 'am', 'an', 'are', 'as', 'at', 'be', 'by', 'for', 'from', 'how', 'in', 'is', 'it', 'of', 'on', 'or', 'that', 'the', 'this', 'to', 'was', 'what', 'when', 'where', 'who', 'will', 'with']; const secondArray = ['i', 'am','a', 'very', 'happy', 'child']; let myList = [] for (let i = 0; i < secondArray; i++){ let is_the_same = 0; for (let j = 0; j < secondRegex; j++){ if(secondArray[i] == secondRegex[j]){ is_the_same = 1; break; } }if (!is_the_same){ myList.push(secondArray[i]); } } console.log(myList);También he intentado esto sin éxito:
for (let i = 0; i < secondArray.length; i++){ let value = secondArray[i]; let coincidence = secondArray.some(value => secondRegex.includes(value)); }if (coincidence = true){ continue; } else{ myList.push(secondArray[i]); }