title: Setting a Javascript if statement with 2 requirements to one line
body: <pre><code>var status = result.locations[index].status;
  var operator = result.locations[index].operator;
  var original = result.locations[index].original;
  var produced = result.locations[index].produced;
  var href = result.locations[index].more;
  </code></pre>
  
  <p>I have the above which each need to be an <code>if</code> statement to check if there is content and my output is the below code.</p>
  
  <pre><code>if (result.locations[index] &amp;&amp; result.locations[index].status){
      var status = result.locations[index].status;
  } else {
      var status = '';
  }
  </code></pre>
  
  <p>I would need to reproduce this per line from the code at the top of the post. What would be the best method to simplify each down to keep the code neater and not produce 5 lines of if statement when 1 or 2 would do.</p>