Solución
solution.tsTypeScript
function rotateString(text: string, k: number): string {
// console.log(text,k)
if (!k || k === 0) return text;
const countToRotatate = text.length > k ? k : text.length;
// console.log(countToRotatate);
const charsToRotate = text.slice(0, countToRotatate);
const charsRest = text.slice(countToRotatate, text.length);
console.log(charsToRotate);
console.log(charsRest);
return charsRest + charsToRotate
// 2,1,0,6,3,4
}
// No modificar: necesario para evaluar el resultado.
export { rotateString };0respuestas