MaXFeeD,
let str = "Ола ОЛА ола";
function fn(str)
{ const obj = {"ола" : "привет"};
for (const [key, value] of Object.entries(obj)) {
let reg = new RegExp(`${key}`, "gi");
str = str.replace(reg, a => a == key ? value : a == key.toUpperCase() ? value.toUpperCase() : value.slice(0,1).toUpperCase() + value.slice(1))
}
return str
}
alert(fn(str));