I want to analyse 2 strings and highlight the words that appear in both strings. So in the example below, apple and cherry would be highlighted. I guess you'd have to put them in an array and loop each array through the other to find matches among the two. I can't find any instructions on this specific task online, so if anyone knows how to do this I would love to know. Thanks
javaScript:
var str1 = "apple banana cherry damson";
var str2 = "apple elderberry cherry fig";
var array1 = str1.split(/\b/);
var array2 = str2.split(/\b/);
//compare arrays to find common words
$(commonWords).addClass('highlight');