This is how i could implement the whole game. Its clear that you will get the answers from both players. I guess that in your chat programm you'd have something of an identifier to check for the users ID and their chat session, so I'm not going to bother with this. I think that the implementation of sending a new "question" for their matching task shouldnt be a problem by just doing a simple
setTimeout(function(){ io.emit('newQuestion', {picture: randomPicture})}, 120000);
The string match should be another task. This could be easily done in javascript. As you are just trying to match complete strings, I would go about this as follows. Suppose you have a chat string1 and chat string2 corresponding to user1 and user2. From there you will need to cross reference all words in string1 with string2. For this string1 has to be broken apart.
var string1 = "apple half";
var string2 = "an apple";
var string1Split = string1.split(" ");
var match = false;
for(i=string1Split.length; i--;) {
result = str.match(/string1Split[i]/g);
if(result.length > 0 && match == false) {
match = true;
}
}
if(match) {
//add points to it
}
I'm not sure if you have to replace the quotes ' " ' in your string1Split[i] but thats just a matter of doing another regexp.