Una función que muestre todas las posibles permutaciones de una palabra que recibe como parametro
function permute(word) { let result = []; if (word.length <= 1) { return [word]; } for (let i = 0; i < word.length; i++) { let firstChar = word[i]; let otherChars = word.substring(0, i) + word.substring(i + 1); let otherPermutations = permute(otherChars); for (let j = 0; j < otherPermutations.length; j++) { result.push(firstChar + otherPermutations[j]); } } return result; }