lundi 12 juin 2017

How to stop a function in javascript?

I want to stop a function when a condition met. But how can I do this, I do not know. For example;

  var key = true;
    if(key=true) {do something } else if(key=false) {do some other thing} 
    x() ;

    function x() {

    if(a=5){dog walks}
    key=false;
    } 

In this case when a=5, my if condition doesn't run the case that belongs (key = false), where do I do wrong?

Aucun commentaire:

Enregistrer un commentaire