let string = 'bob' let index = 2 string = string.substring(0, index) + 'x' + string.substring(index + 1) console.log(string) // [Log]: box