Why do I get a double console message for this function?
<p>I have the following function:</p>

<pre><code>var checkNameLenght = function(name,nameLenght,allowedLenght,defaultName) {

    var result;

    if(!(nameLenght &lt;= allowedLenght) || !(/[^a-z]/i.test(name))) {
        result = name; 
    }
        else {
            if(opts.debug == true) {
                console.log(name+' is to long or contains special characters / numbers | Please choose a name shorter than '+allowedLenght+' characters or remove any character / number');
            }
            result = defaultName;
        }

    return result;

}
</code></pre>

<p>I use it to check the length of a string ( in my case the value of an input ) and if it contains any special characters or numbers.</p>

<p>I use it like so:</p>

<pre><code>var input = 'Somevalue';

checkNameLenght(input ,input.length,16,'Username');
</code></pre>

<p>The only thing is that if the <code>input</code> string contains some of the above conditions than the console will output the message twice. </p>

<p>Why is that happening ?</p>
