Solución
solution.tsTypeScript
function camelToSnake(text: string): string {
const l = 'abcdefghijklmnopqrstuvwxyz'
.split('')
.reduce((acc, l) => ({...acc,[l.toLocaleUpperCase()]: true}), {})
let s = ""
for (let i = 0; i < text.length; i++) {
if (text[i] in l) {
s += "_" + text[i].toLocaleLowerCase()
} else {
s+= text[i]
}
}
return s;
}
// No modificar: necesario para evaluar el resultado.
export { camelToSnake };0respuestas