When given 7 letters, find all possible words with length 3 to 7 I am writing a program in JavaScript to find all possible words given 7 letters. The words have to be 3 or more characters, and for right now I am limiting it to 7 characters long. The code below works, but takes forever to complete and I would like to speed it up. Would recursion help?

Thanks for any suggestions.

The variable wordList is an array of 60,000 words.

    function isWord(word){
        var found = wordList.indexOf(word);
        if(wordList[found]===word) return true;
            else return false;
    }
    for(var i=0; i&lt;letters.length; i++) {
        for(var j=0; j&lt;letters.length; j++) {
            for(var k=0;k&lt;letters.length; k++) {
                if(isWord(letters[i]+letters[j]+letters[k]))
                    w.push(letters[i]+letters[j]+letters[k])
            }
        }
    }
    for(var i=0; i&lt;letters.length; i++) {
        for(var j=0; j&lt;letters.length; j++) {
            for(var k=0; k&lt;letters.length; k++) {
                for(var l=0; l&lt;letters.length; l++) {
                    if(isWord(letters[i]+letters[j]+letters[k]+letters[l]))
                    w.push(letters[i]+letters[j]+letters[k]+letters[l])
                }
            }
        }
    }
    for(var i=0; i&lt;letters.length; i++) {
        for(var j=0; j&lt;letters.length; j++) {
            for(var k=0; k&lt;letters.length; k++) {
                for(var l=0; l&lt;letters.length; l++) {
                    for(var m=0; m&lt;letters.length; m++) {
                        if(isWord(letters[i]+letters[j]+letters[k]+letters[l]+letters[m]))
                        w.push(letters[i]+letters[j]+letters[k]+letters[l]+letters[m])
                    }
                }
            }
        }
    }
    for(var i=0; i&lt;letters.length; i++) {
        for(var j=0; j&lt;letters.length; j++) {
            for(var k=0; k&lt;letters.length; k++) {
                for(var l=0; l&lt;letters.length; l++) {
                    for(var m=0; m&lt;letters.length; m++) {
                        for(var n=0; n&lt;letters.length; n++) {
                            if(isWord(letters[i]+letters[j]+letters[k]+letters[l]+letters[m]+letters[n]))
                            w.push(letters[i]+letters[j]+letters[k]+letters[l]+letters[m]+letters[n])
                        }
                    }
                }
            }
        }
    }
    for(var i=0; i&lt;letters.length; i++) {
        for(var j=0; j&lt;letters.length; j++) {
            for(var k=0; k&lt;letters.length; k++) {
                for(var l=0; l&lt;letters.length; l++) {
                    for(var m=0; m&lt;letters.length; m++) {
                        for(var n=0; n&lt;letters.length; n++) {
                            for(var o=0; o&lt;letters.length; o++) {
                                if(isWord(letters[i]+letters[j]+letters[k]+letters[l]+letters[m]+letters[n]+letters[o]))
                            w.push(letters[i]+letters[j]+letters[k]+letters[l]+letters[m]+letters[n]+letters[o])
                            }
                        }
                    }
                }
            }
        }
    }
You are forming each possible combination, and look for it in the dictionary. That indeed takes forever. You'd be in a better shape doing it other way around. Read the dictionary word by word, and for each word check if it is composed by your letters. In pseudocode,

    for letter in word
        if letter not in letters
            return false
    return true