Solución
solution.tsTypeScript
function compressString(text: string): string {
let count = 0;
let pairValues = []
for ( let i : number = 0; i < text.length; i++ ) {
if ( text[i] === text[ i + 1 ] ) {
count+=1
pairValues.splice(i, 1, '')
} else {
count+=1
pairValues.push(text[i]+count)
count = 0
}
}
return pairValues.filter( c => c != '' ).join('');
}
// No modificar: necesario para evaluar el resultado.
export { compressString };0respuestas