-
-
Save parzibyte/ee0864b033b9ec9089ec7f934c2e812e 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 obtenerCombinaciones = palabra => { | |
// https://parzibyte.me/blog | |
const combinaciones = []; | |
for (let i = 0; i < palabra.length; i++) { | |
// Primero la letra actual | |
let combinacion = palabra.charAt(i); | |
combinaciones.push(combinacion); | |
for (let j = i + 1; j < palabra.length; j++) { | |
combinacion += palabra.charAt(j); | |
// Y luego lo de la primera letra con todas las que le siguen hasta el final | |
combinaciones.push(combinacion); | |
} | |
} | |
return combinaciones; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment