Function in JS returns undefined
<p>I have the following problem. The alert allways returns undefined, but I know it has a value. What am I doing wrong. I'm out of solutions...</p>

<p>I'm using JQUERY jquery-1.4.2.min.js</p>

<p>Tnx in advance</p>

<pre><code>$(document).ready(function(){
    $('#generateButton').click(createIBAN);
});

function createIBAN(){
    //---- First check if a bank has been selected,
    //---- if not, then show error
    if($('#selectBank').val()==''){
        alert('Selecte a bank!');
    }else{
        var bankAccount =   generateBankAccount();
        alert(bankAccount);
    }
    return false;
}

function generateBankAccount(){
    //---- Create "elfproef" bankaccount
    var bankAccount =   '';
    //---- Set the amount of digits in a bankaccount
    digitAmount     =   9;
    //---- Make random digitstring
    for (var i = 0; i &lt; digitAmount; i++) {
        bankAccount += Math.floor(Math.random() * digitAmount);
    }
    //---- validate the string, if not "elf-proef"
    if (elfProef(bankAccount)==false) {
        //---- regenerate the string
        generateBankAccount();
    }else{
        return  bankAccount;
    }
}

function elfProef(bankAccount) {
    //---- set sum to 0 and start the for-loop for counting
    var sum = 0;
    for (var i = 0; i &lt; digitAmount; i++) {
        //---- for every digit multiply it times 9 - number 
        //---- of the digit and count it to the sum var
        sum += bankAccount.charAt(i) * (digitAmount - i);
    }
    //---- Check if sum can be devided by 11 without having ##,##
    if(sum % 11==0){
        //---- return true means string is "elf-proef"
        return true; 
    }else {
        //---- String is not "elf-proef", try again
        return false;
    }
}
</code></pre>
