title: How to add an image to a random variable in JavaScript?
body: <p>So, I'm starting with JavaScript and got an assignment with a randomizer-ish and goes like this:</p>
  
  <p>There are two usernames reserved, user1 and user2, whenever they put their name on the prompt(), they get a message that they won a car(the car is random).</p>
  
  <p>I made it to the part where the user gets the message, but the problem is, I have to show an image of the car and the message, and I don't know how to do that.</p>
  
  <p>Any advice on how to solve that?</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>var username = prompt("Hello, who are you?");
  var cars = [
    "car1",
    "car2",
    "car3"
  ];
  
  if (username === "user1") {
    var randomCar = Math.floor(Math.random() * cars.length);
    var car = cars[randomCar];
    document.write("&lt;h1&gt;Congratulations " + username + " you won a " + car + "!&lt;/h1&gt;");
  } else {
    if (username === "user2") {
      var randomCar = Math.floor(Math.random() * cars.length);
      var car = cars[randomCar];
      document.write("&lt;h1&gt;Congratulations " + username + " you won a " + car + "!&lt;/h1&gt;");
    } else {
      document.write("&lt;h1&gt;Sorry " + username + " you didnt won this time." + "&lt;/h1&gt;");
    }
  }</code></pre>
  </div>
  </div>
  </p>