JavaScript function that generates all combinations of a string. 1

JavaScript function that generates all combinations of a string.

function combu(s){
var buff = [];
var res = [];
for (i=0;i

Here is what the above code is Doing:
1. Create an empty array called buff.
2. Create an empty array called res.
3. Loop through the string.
4. Push the current letter into buff.
5. While there is a value in res at the current index, push the current letter into buff.
6. Concatenate buff into res.
7. Return res.

Similar Posts