Solución
solution.tsTypeScript
function rotateLeft(str: string, positions: number): string {
if (str.length === 0) return str
const cutPos = positions % str.length
return cutPos === 0
? str
: str.slice(cutPos) + str.slice(0, cutPos)
}
// No modificar: necesario para evaluar el resultado.
export { rotateLeft };
0respuestas