title: Attempting to compare textbox with array element
body: <p>I am trying to compare user entered text in a textbox with an element in an array but am having difficulties.</p>
  
  <pre><code>function checkAns()
  {
  var str = imageArray[randNum];
  var n = str.indexOf(document.getElementById('textBox').value);
  if(n == -1)
  {
      alert("Wrong Answer")
  }
  else
  {
      alert("Right Answer")
  }
  }
  </code></pre>
  
  <p>The user input should either match part of the the specified string in the array element and return Right Answer or not match at all and return Wrong Answer.</p>
  
  <pre><code>&lt;input type=”text” id=”textBox” value=””&gt;
  &lt;input type=”button” value=”Check” onclick=”checkAns()”&gt;
  </code></pre>
  
  <p>I added the code for my textbox and button if that is useful.</p>