title: How to check if the user input is the correct answer or not?
body: <p>I am making an online application for children that picks a random image from a database using the following code:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  var random_images_array = ['apple.gif', 'book.gif',...]
  
  function getRandomImage(imgAr, path) 
  {
  path = path || 'images/';
  var num = Math.floor( Math.random() * imgAr.length );
  var img = imgAr[ num ];
  var imgStr = '&lt;img src="' + path + img + '" alt = ""&gt;';
  document.write(imgStr); document.close();
  }
  &lt;/script&gt;
  </code></pre>
  
  <p>My question is how can I tell the computer whether the input from the user is the correct answer or not?
  For example if the programme is showing the apple image, the user should type “apple” and the system should return a “correct” message.
  p.s. the name of the images represent the content of that image.</p>