Why I can not do “or” in my JavaScript if condition?
<p>Hi I have following function which behaves differently when I add an OR condition in it. </p>

<pre><code>&lt;script&gt;
function checkfield(obj)
{
    var full_name = obj.upload_image.value.toLowerCase();
    var full_length = parseInt(full_name.length);
    var dotAt = parseInt(full_name.lastIndexOf("."));

    var ext = full_name.substring((dotAt+1), full_length);
    if(ext == "jpg" || ext == "png")
        {
            //alert("Sorry! allowed file types are .png, .gif, .jpg");
            //return false;
            console.log("Correct Extention");
        }
        else{
            console.log("Wrong extention");
        }


    return false;
}
&lt;/script&gt;
</code></pre>

<p>What ever I give before the <code>||</code> operator it works fine and the second one fails. please can some one pick out what i am doing wrong or how this should be done. </p>
