title: Javascript Elevator Program
body: <p>I'm creating an elevator in HTML/CSS/Javascript and running into an issue in some parts of the javascript.</p>
  <p>I am trying to log each button pressed, to then have the elevator go to each floor in order. I'm currently adding each each floor to an array.</p>
  <p>Everytime I run the program the elevator runs through the entire array for each iteration.</p>
  <p>How can I add each floor to the array, and then one the floor has been visited, it gets removed and the program keeps moving through the existing array?</p>
  <h3>JavaScript</h3>
  <pre><code>var Elevator = (function Elevator() {
  
    var floors = 10,
    origin = 1,
    queue = [],
    current, 
    isMoving = false,
    destination;
    
    
  
    
    // this gets the floor being click
    // and assigns the value of destination to the new floor
    function getFloors(event) {
      event.preventDefault();
      destination = $(this).attr('href');
      console.log(destination);
      if (destination !== origin){
       isMoving = true;
       queue.push(destination);
       console.log(queue);
     }
   }
  
   function moveFloors(destination){
   }
  
    // this acts as a controller
    // for all events and how and what we bind them to
    function bindEvents() {
      $('.btn').on('click', getFloors);
    }
    // this runs the bind events
    // and only runs the bind events
    function init(){
      bindEvents();
    }
    // this makes the init method public for invoking
    return {
      init: init()
    };
  })();
  
  Elevator.init();
  </code></pre>