jeudi 30 juin 2016

If-else statements in JS

I have a bug in my code and I can't find it. Can you help me, please?

var pass = prompt("Please enter your password");
        var lung = pass.length;
        var gutlng = 0;
        document.getElementById("lungime").innerHTML =
        "Your password has " + lung + " characters";


        if(lung== 0 ){
                document.getElementById("check").innerHTML = "Please enter a relevant password."
                gutlng = 0;
        }       
        if(lung== 1 ){
                document.getElementById("check").innerHTML = "Please enter a relevant password."
                gutlng = 0;
        }
        if(lung<8 && lung!=1 && lung!=0){
        document.getElementById("check").innerHTML = "It is a bit to short. Please try again.";
          gutlng = 0;
        }

        if(lung>8 && lung<20){
                document.getElementById("check").innerHTML = "It is perfect! Proceed to the next step!"
                gutlng = 1;
        }

        if(lung>20){
                document.getElementById("check").innerHTML = "It is too long. PLease try again"
                gutlng = 0;
        }

        
     var fb = 0;
        var tw = 0;
        var sc = 0;
        var yh = 0;
        var gm = 0;
        var is = 0;
    

        if(gutlng == 1){
                var fb = 1;
                var tw = 1;
                var sc = 1;
                var is = 1;
                var yh = 1;
                var gm = 1;
        }
        
        if(gutlng == 0){
                var fb = 0;
                var tw = 0;
                var sc = 0;
                var is = 0;
                var yh = 0;
                var gm = 0;
        }

        if(fb == 1){
                document.getElementById("fb").innerHTML = "GOOD";
       
        if(fb == 0){
                document.getElementById("fb").innerHTML = "NOT GOOD";
        }

        if(tw == 1){
                document.getElementById("tw").innerHTML = "GOOD";
        }
        if(tw == 0){
                document.getElementById("tw").innerHTML = "NOT GOOD";
        }

        if(sc == 1){
                document.getElementById("sc").innerHTML = "GOOD";
        }
        if(sc == 0){
                document.getElementById("sc").innerHTML = "NOT GOOD";
        }

        if(is == 1){
                document.getElementById("is").innerHTML = "GOOD";
        }
        if(is == 0){
                document.getElementById("is").innerHTML = "NOT GOOD";
        }

        if(yh == 1){
                document.getElementById("yh").innerHTML = "GOOD";
        }
        if(yh == 0){
                document.getElementById("yh").innerHTML = "NOT GOOD";
        }

        if(gm == 1){
                document.getElementById("gm").innerHTML = "GOOD";
        }
        if(gm == 0){
                document.getElementById("gm").innerHTML = "NOT GOOD";
        }

I tried to fix it, but the bug doesen't appeear.Thank you for your time! Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!CheersCheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!Cheers!

Aucun commentaire:

Enregistrer un commentaire