possibly missing the point here, but...
Code:
var visitorName = "new word 1";
var loc = "here";
var myOldString = "Hello word1! I hope you enjoy your stay word2.";
var myNewString = myOldString.replace(/word1/g, visitorName).replace(/word2/g, loc);
?