let str: string = 'javascript typescript node.js php';
const lastIndex: number = str.lastIndexOf('t');
const replace_char: string = 'W';
str = str.substring(0, lastIndex) + replace_char + str.substring(lastIndex + 1);
console.log(str);
/*
run:
"javascript typescripW node.js php"
*/