I have this string and for example i need to get the the word green eyes from specific string that is sperated by a comma like this example
young lady , beautiful , green eyes , wearing shirt , wearing necklace
I want to get for example green eyes using the word eyes for example
how can I achieve this ?
>Solution :
First split the string, then filter trough the array to find the words that match
const str = "young lady,beautiful,green eyes,wearing shirt,wearing necklace";
const findWord = (word) => str.split(",").filter(x => x.includes(word))
console.log(findWord("green"))