How do I search through each word in a string of a
that matches an array?
Here is my prototype:
$("#latte").on("click", function() {
$('#lattePool').load('dictionary.txt');
var text = $("#lattePool").text().toUpperCase();
var words = text.split("\n");
var dictionary = new Array();
for(var i=0; i < words.length; i++) {
dictionary[i] = words[i];
};
$("#notes p").each(function(){
var nameFound = $.inArray($(this).text().trim().toUpperCase(), dictionary);
if (nameFound === -1){
} else {
alert($(this).text() + " found in array");
}
});
});
When user click on #latte button, it loads a dictionary.txt text into a temporary pool call #lattePool, then it breaks down into individual words and then into a very long array.
Then, wehn user paste something in a contenteditable div #notes, it needs to find each words in the
tag with all the words in the dictionary array.
currently it only works with a single word in a
, not a long string.
Any ideas to make it check through each word of a
from an array?
Many thanks~!!!