let a = 'I was only a child when I was 15. Everbody were calling me a child';
String.prototype.replaceAdvanced = function(find, replace) {
let text = this;
if(typeof find === typeof [] && typeof replace === typeof []){
find.forEach((value, index) => {
let pattern = new RegExp(value, 'g');
text = text.replace(pattern, replace[index]);
});
} else{
let pattern = new RegExp(find, 'g');
text = text.replace(pattern, replace);
}
return text;
}
let replaced = a.replaceAdvanced(['I', 'child'], ['İbrahim', 'Sinem']);
console.log(replaced);