Replaces a substring at a specific index with a new string
export const replaceAt = function (str: string, index: number, length: number, replacement: string): string { return str.substring(0, index) + replacement + str.substring(index + length);}; Copy
export const replaceAt = function (str: string, index: number, length: number, replacement: string): string { return str.substring(0, index) + replacement + str.substring(index + length);};
The original string
The starting index for replacement
The number of characters to replace
The replacement string
A new string with the replacement applied
Replaces a substring at a specific index with a new string
Source