title: Check If Statement when you are dynamically creating something?
body: <p>I am dynamically creating rows in my table using JavaScript. I need to add <code>If</code> statement inside a <code>&lt;td&gt;</code> which I am creating dynamically. Inside my <code>&lt;td&gt;</code> I have an anchor tag <code>&lt;a&gt;</code>. I need to add anchor tag only if it satisfies my <code>If</code> statement. Following is my code:</p>
  
  <pre><code>var IsAdmin = true;
  var row;
  row = "&lt;tr&gt;&lt;td&gt;" + if(IsAdmin == true){ + "&lt;a href='#'&gt; &lt;/a&gt;" + } + "&lt;/td&gt;&lt;/tr&gt;"
  </code></pre>
  
  <p>I am getting following error in my console:</p>
  
  <blockquote>
    <p>Uncaught Syntax Error: Unexpected token if</p>
  </blockquote>
  
  <p>What am I doing wrong?</p>