Skip to content
Fabian Morón Zirfas edited this page Jun 17, 2015 · 2 revisions
    /*
    Use structures to make decisions and repetition  
    with more operators for that  
    < > <= >= == || && !=  
    */

####Conditional

if ( ){ }

{ } else { }

{ } else if ( ) { }

    /*
    create conditions like this
    */

    var a = 5;
    var b = 7;
    var c = 13;

    if(a > b){
        alert(b + " is smaller than " + a);
    }else{
        alert(a + " is smaller than " + b);    
    }

    if((a + b) >= c){
        alert(c);
        }else if((a + b) == (b + a)){
            alert("equal");
        }else if((a > c) && (b > c)){
            alert("combined");
    }else{
         alert("something else");
    }

if(a != "foo"){
    alert("bah!");
    }
Clone this wiki locally