Given two strings, how can I do something if both strings have one word in common?
For example: "foo bar" and "foo line" both have the word "foo". The strings could be 3 words long or more, like "foo bar" and "blue foo line".
What I’ve tried so far:
var m = "foo bar";
var n = "foo line";
if(m.match(/n/g)){
alert("match");
}
http://jsbin.com/iwalam/3/edit
better version :