I have multiple excel columns with hundreds of data. I want to find the same words in these columns. For example, First Column: dog rat catch act some cat fork apple, Second Column: fork dog lamp song apple some hymn candle,etc., and output would be "dog, some, fork, apple".
I found this code from Intersecting texts to find common words this thread. It works for strings but, doesn't work for textareas and inputs. I tried to modify it for my problem but, I failed.
Thanks in advance.
var t1 = document.getElementById('first').value;
var t2 = document.getElementById('second').value;
function intersect() {
var set = {};
[].forEach.call(arguments, function(a,i){
var tokens = a.match(/\w+/g);
if (!i) {
tokens.forEach(function(t){ set[t]=1 });
} else {
for (var k in set){
if (tokens.indexOf(k)<0) delete set[k];
}
}
});
return Object.keys(set);
}
console.log(intersect(t1, t2));
<textarea id="first"></textarea>
<textarea id="second"></textarea>