title: How to concatenate Javascript variable in HTML image source tag
body: <p>How do you concatenate a Javascript variable into the url of a HTML image source tag?   I have tried <code>.$ANSWER.</code> <code>"$ANSWER"</code> and <code>+$ANSWER+</code> and none of these are working.</p>
  
  <p>Do I need to use <code>getElementbyID</code>?</p>
  
  <p>I have a folder of images named <code>cat.jpg</code>, <code>dog.jpg</code>, etc and I have a javascript array of these animal names.</p>
  
  <p>One of them is chosen as <code>$ANSWER</code> and I want to then display the image, using the variable <code>$ANSWER</code>.</p>
  
  <p>I have scoured the internet for any example of how to do this but can't find any.</p>
  
  <p>What I have below is my best guess of how to write it, but I get "Not found" in the console log.  The picture are in the folder, as this was working in PHP before I rewrote this in Javascript.</p>
  
  <pre><code>&lt;div&gt;
  &lt;img id="ANSWER" src='pictures/animals/$ANSWER.jpg' width=80% height=auto &gt;   
  &lt;/div&gt;
  &lt;script&gt;
  document.getElementById("ANSWER").src='pictures/animals/$ANSWER.jpg';
  &lt;/script&gt;
  </code></pre>
  
  <p>Also, if there is an easy way to do this in JQuery, I would love to know.</p>