title: Different ways of writing the "if" statement
body: <p>I have seen different ways of writing an <code>if</code> statement.</p>
  <p>Which one do you prefer and why?</p>
  <h3>Example 1:</h3>
  <pre><code>if (val % 2 == 1){output = “Number is odd”;}else{output = “Number is even”;} 
  </code></pre>
  <h3>Example 2:</h3>
  <pre><code>if (val % 2 == 1)
  {
      output = “Number is odd”;
  }
  else
  {
     output = “Number is even”;
  }
  </code></pre>
  <h3>Example 3:</h3>
  <pre><code>if (val % 2 == 1)
  output = “Number is odd”;
  else
  output = “Number is even”;
  </code></pre>
  <h3>Example 4:</h3>
  <pre><code>if (val % 2 == 1){
  output = “Number is odd”;
  } else {
  output = “Number is even”;
  }
  </code></pre>
  <h3>Similar question:</h3>
  <blockquote>
  <p><a href="https://stackoverflow.com/questions/359732">Why is it considered a bad practice to omit curly braces?</a></p>
  </blockquote>