Let's say I have a list of words and a string. I want a new array that represents the frequency of each word in the string from the list of words. Also, each index of the word should be the same and the length of the array is the same as listWords
.
listWords = ['Noodles', 'Instant', 'Flavour', 'Ramen', 'Chicken', 'Flavor', 'Spicy', 'Beef']
string = "Cup Noodles Chicken Vegetable Noodles"
The resulting array should look like this:
Each index represents the frequency of each word in the list, and 0 otherwise
result = [2, 0, 0, 0, 1, 0, 0, 0]