'use strict';
// Plunker may spam in console
console.clear();
// Input string
var string = 'The quick brown fox jumped over the lazy dog.';
// Replacements
var matches = {
'quick': 'slow',
'brown': 'black',
'fox': 'bear'
};
// Gogo
var result = string.replace(
// Match all keys
new RegExp(Object.keys(matches).join('|'), 'g'),
// Just get value from replacements
function(match) {
return matches[match];
}
);
// Bingo
console.log(result);