-
-
Save parzibyte/2bf274f7ccdc35cf2b7aeeee3084885d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const caracteresUnicos = cadena => { | |
// https://parzibyte.me/blog | |
let unicos = ""; | |
for (letra of cadena) { | |
if (!unicos.includes(letra)) { | |
unicos += letra; | |
} | |
} | |
return unicos; | |
}; | |
const cadena = "the quick brown fox jumps over the lazy dog"; | |
const caracteres = caracteresUnicos(cadena); | |
console.log("Los caracteres únicos de '%s' son '%s'", cadena, caracteres); | |
const caracteresOrdenados = caracteres.split("").sort().join(""); | |
console.log("Solo como curiosidad, si ordenamos los caracteres obtenemos '%s'", caracteresOrdenados); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment