title: How to check a series of numbers in javascript
body: <p>I am making a digital vault lock with javascript where users need to fill in four numbers in the right order to unlock something on the page. </p>
  
  <p>The page consists of a textbox where they fill in a number under 10 and push a button to send the number. They have to do this 4 times and if the numbers and the order are correct (4 5 2 7 for example), it will unlock and a picture will show.</p>
  
  <p>I tried to make it work with a "if" structure, but cant seem to think of the right way to do this. </p>
  
  <pre><code>function checkingcombination (){
        if(numberpushed == 4){
          if(numberpushed == 5){
            if(numberpushed == 2){
              if(numberpushed == 7){
                 alert("lock unlocked, welcome");
              }
              else{
               alert("wrong combination");
               return;
              } 
            }
            else{
             alert("wrong combination");
             return;
            }
          }
          else{
            alert("wrong combination");
            return;
          }
        }
        else{
          alert("wrong combination");
          return;
        }
  }
  </code></pre>