title: How to use a variable as a filepath in JS?
body: <p>While trying to build some dynamic content for a webpage, I encountered a strange problem. I did some research but I could not find anything that would help me...</p>
  
  <p>Here is my code where I try to change the background image of a div. 
  The file path for the background image is stored in an object which is received as JSON and parsed to a javascript object. When I fill the innerHTML of the div with the content of the filepath variable, the correct URL is displayed. 
  And when I write this exact URL into the backgroundImage URL, the correct picture is displayed.
  However when I try to replace the file path with the variable, nothing happens.</p>
  
  <pre><code>    var myObj = JSON.parse(this.responseText);
              var URL = JSON.stringify(myObj.imageURL);
              newbox.style.backgroundImage = "url('myObj.imageURL')";
              newbox.innerHTML += myObj.Content;
              newbox.innerHTML += myObj.imageURL;
              insert.append(newbox);
  </code></pre>
  
  <p>In my code you can see that I also tried to stringify the value of <code>myObj.imageURL</code> and use this as the file path. But this did not work either.</p>
  
  <p>EDIT: the filepath stored in myObj.imagURL looks like this: images/crew.jpg</p>
  
  <p>EDIT 2: The problem has been solved by Manuel Otto:</p>
  
  <pre><code>    newbox.style.backgroundImage = "url("+myObj.imageURL+")";
  </code></pre>
  
  <p>Thanks for all the advise!</p>