title: How to make a javascript value equal to the value that I receive from my Razor code
body: <p>I'm new to MVC and am not sure if this is even possible but I want to know how I can make a variable inside of my javscript function be to a equal the value that I am grabbing from my razor code.</p>
  
  <p>Here is my code </p>
  
  <pre><code>function create() {
  
          var site
  
          @if (@so.invSiteID == null) {
              var siteRazor = 0;
          }
          else {
              var siteRazor = @so.invSiteID;            
          }
  }
  
  </code></pre>
  
  <p>So is it possible for me to make my "siteRazor" equal to my "site" variable?</p>
  
  <p>Also, I tried this</p>
  
  <pre><code>if (@so.invSiteID == null) {
              site = 0;
          }
          else {
              site = @so.invSiteID;            
          }
  
  </code></pre>
  
  <p>But it didn't matter if the statments were true or false it would always run through both. If I can get a brief explanation as to why that didn't work that would be awesome</p>