15,039,037 members
See more:
```0

I want to remove the single string and want to keep string with minimum length 3 and above i tried to access string with this if(result.string >= 3) but it is giving array length so i tried to access string but i cant. so please anybody who can help me```

What I have tried:

```let stringCombinations = (str) => {
let strLength = str.length;
let result = [];
let currentIndex = 0;
while (currentIndex < strLength) {
let char = str.charAt(currentIndex);
let x;
let arrTemp = [char];
for (x in result) {
arrTemp.push("" + result[x] + char);
}
result = result.concat(arrTemp);
currentIndex++;
}
return result;
};

This is my ouput

This is what I want
Posted
Updated 6-Jul-21 0:27am
Patrice T 5-Jul-21 15:28pm

And you have a question or a problem ?
Happy kaul 5-Jul-21 15:34pm

Both
Patrice T 5-Jul-21 16:12pm

And you plan to describe them ?
Richard MacCutchan 6-Jul-21 3:37am

What is the structure of the input data?
Happy kaul 6-Jul-21 3:40am

Input is "blaze"

But you can put any input. it will give combination of that word but with length minimum of 3 and can be more than 3
Richard MacCutchan 6-Jul-21 7:21am

How do you get `"BLD", "BAD", "LAD", "BLAD"` etc. from "BLAZE"?

## Solution 1

I don't know Javascript but have a sense of what your code is doing. You're finding all combinations except for the empty string, which is a good start. But I see nothing in your code that filters out combinations of less than 3 letters. It looks like you build on such combinations, so it would probably be easiest to fix the code by removing them before you `return result`.

## Solution 2

Replace your
JavaScript
`return result;`
with
JavaScript
`return result.filter(x => x.length >= 3);`
Because the way you generate the combinations, you can't filter short combinations earlier.

Cheers