title: Bulb Challenge in Javascript
body: <p>The question goes "Light bulbs are connected by a wire. Each bulb has a switch associated with it, however due to faulty wiring, a switch also changes the state of all the bulbs to the right of current bulb. Given an initial state of all bulbs, find the minimum number of switches you have to press to turn on all the bulbs. You can press the same switch multiple times".</p>
  
  <p>I found this answer online but I'm not 100% sure about what the ternary operator is doing in the loop. What is <code>var initial</code> and <code>var current</code> doing?</p>
  
  <pre><code>function bulbs(arr){
    var switched = 0;
      for(var i = 0; i &lt; arr.length; i++){
        var initial = arr[i] === 1,
            current = (switched % 2 === 1)? !initial:initial;
        if(current === false){
          switched++;
        }
      }
    return switched;
  }
  </code></pre>