[Solved] Find the string in array which doesn’t contain the character in JavaScript


Here is you your example code

let wordarray=["defeat","dead","eaten","defend","ante","something"];
word ="defantmsi";
posarray="entfdenis";
function findMissingCharacters(str1,str2){
	let result = [] //array which will be returned
	for(let letter of str1){
    //check if str2 doesnot contain letter of str1
		if(!str2.includes(letter)) result.push(letter);
	}
	return result;
}
let missing = findMissingCharacters(word,posarray);
//filtering the wordarray
let strings = wordarray.filter(word =>{
  //this boolean will be returned
	let contains = false;
	missing.forEach(letter => {
    //check if any of letter in missing is in word
		if(word.includes(letter)) contains = true;
	})
  //we don't want strings for which contains is true
	return !contains;
})
console.log(strings);

solved Find the string in array which doesn’t contain the character in JavaScript