title: Changing a variable inside a if - jade/pugjs
body: <p>I'm trying to make a div have a location inside of it based on the state of two variables, for example if <code>$city = 'New York'</code> and <code>$state = 'NY'</code> the div would display <code>New York, NY</code>. However, it's not working and I think it has to do with scoping. Here's my jade:</p>
  
  <pre><code>$city = data.City
  $state = data.State
  $locString = ""
  
  if $city != ""
      $locString = $locString + $city
  if $city != "" &amp;&amp; $state != ""
      $locString = $locString + ", "
  if $state != ""
      $locString = $locString + $state
  
  .location #{$locString}
  </code></pre>
  
  <p>This is ending with $locString being empty, but if I print off $locString inside the if statements it has only the most recently added value, suggesting that it is redeclaring a local copy of the variable inside of each if statement. I can't find anything about this in the reference <a href="http://jade-lang.com/reference/" rel="nofollow">http://jade-lang.com/reference/</a></p>