title: Why is JavaScript RegExp not working in Firefox?
body: <p>Could someone tell me why my code is not working in Firefox? It's fine in other browsers, but if I type in 1000 in the Cash at Bank cell, it's marking it as an incorrect answer (highlighting in red and displaying the incorrect feedback). The other validation / testing of other cell entries doesn't work either.</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>function checkAnswers() {
    document.querySelectorAll('[data-answer]').forEach(item =&gt; {
      if (RegExp(item.dataset.answer).test(item.innerText)) {
        item.style.backgroundColor = "#e2edde";
        item.title = item.dataset.correct;
      } else {
        item.style.backgroundColor = "#fce9e9";
        item.title = item.dataset.incorrect;
      }
    })
    document.getElementById("feedbackdiv").style.display = "inline-block";
    document.getElementById("feedback").innerText = "Click in each highlighted cell for more information.";
    document.getElementById("feedbackdiv").style.backgroundColor = "rgb(234, 243, 250)";
    document.getElementById("checkbutton").style.display = "none";
    document.getElementById("retrybutton").style.display = "block";
  
  }
  
  function showFeedback() {
    var cell = document.activeElement;
    if (cell.style.backgroundColor == "rgb(226, 237, 222)") {
      document.getElementById("feedback").innerText = cell.dataset.correct;
      document.getElementById("feedbackdiv").style.backgroundColor = "rgb(226, 237, 222)";
    }
    if (cell.style.backgroundColor == "rgb(252, 233, 233)") {
      document.getElementById("feedback").innerText = cell.dataset.incorrect;
      document.getElementById("feedbackdiv").style.backgroundColor = "rgb(252, 233, 233)";
    }
  
  }
  
  function showSolution() {
    document.querySelectorAll('[data-answer]').forEach(item =&gt; {
      item.style.backgroundColor = "#eaf3fa";
      item.innerText = item.dataset.solution;
    })
    document.getElementById("feedbackdiv").style.display = "inline-block";
    document.getElementById("feedback").innerText = "In the answer you can see that Cash at bank has increased by CU1,000 and equity has increased by CU1,000.";  document.getElementById("feedbackdiv").style.backgroundColor = "rgb(234, 243, 250)";  document.getElementById("checkbutton").style.display = "none";
    document.getElementById("solution").style.display = "none";  document.getElementById("retrybutton").style.display = "block";
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;table border="1"&gt;
    &lt;tbody&gt;
      &lt;tr&gt;
        &lt;th scope="col"&gt;&amp;nbsp;&lt;/th&gt;
        &lt;th scope="col"&gt;Cash at &lt;br&gt; Bank &lt;/th&gt;
        &lt;th scope="col"&gt;Vehicle&lt;/th&gt;
        &lt;th scope="col"&gt;Equipment&lt;/th&gt;
        &lt;th scope="col"&gt;Supplies&lt;/th&gt;
        &lt;th scope="col"&gt;Accounts &lt;br&gt; Receivable &lt;/th&gt;
        &lt;th scope="col"&gt;&amp;nbsp;&lt;/th&gt;
        &lt;th scope="col"&gt;Accounts &lt;br&gt; Payable &lt;/th&gt;
        &lt;th scope="col"&gt;&amp;nbsp;&lt;/th&gt;
        &lt;th scope="col"&gt;Otok, Equity &lt;/th&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;(6)&lt;/td&gt;
        &lt;td id="cashanswer" title="Click in a cell to type your entry" contenteditable="true" data-answer="^(1000|1\,000)$" data-solution="1,000" data-incorrect="Incorrect. We neeed to show that Cash at Bank has increased by CU1,000." data-correct="Well done. Cash at Bank has increased by CU1,000."
          onfocus="showFeedback()"&gt;&lt;/td&gt;
        &lt;td id="vehicleanswer" title="Click in a cell to type your entry" contenteditable="true" data-answer="^$" data-incorrect="Incorrect. This cell should be left blank." data-correct="Well done. This cell should be left blank." onfocus="showFeedback()"&gt;&lt;/td&gt;
        &lt;td id="equipmentanswer" title="Click in a cell to type your entry" contenteditable="true" data-answer="^$" data-incorrect="Incorrect. This cell should be left blank." data-correct="Well done. This cell should be left blank." onfocus="showFeedback()"&gt;&lt;/td&gt;
        &lt;td id="suppliesanswer" title="Click in a cell to type your entry" contenteditable="true" data-answer="^$" data-incorrect="Incorrect. This cell should be left blank." data-correct="Well done. This cell should be left blank." onfocus="showFeedback()"&gt;&lt;/td&gt;
        &lt;td id="receivableanswer" title="Click in a cell to type your entry" contenteditable="true" data-answer="^$" data-incorrect="Incorrect. This cell should be left blank." data-correct="Well done. This cell should be left blank." onfocus="showFeedback()"&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td id="payableanswer" title="Click in a cell to type your entry" contenteditable="true" data-answer="^$" data-incorrect="Incorrect. This cell should be left blank." data-correct="Well done. This cell should be left blank." onfocus="showFeedback()"&gt;&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
        &lt;td id="equityanswer" title="Click in a cell to type your entry" contenteditable="true" data-answer="^(1000|1\,000)$" data-solution="1,000" data-incorrect="Incorrect. We neeed to show that Equity has increased by CU1,000." data-correct="Well done. Equity has increased by CU1,000."
          onfocus="showFeedback()"&gt;&lt;/td&gt;
      &lt;/tr&gt;
    &lt;/tbody&gt;
  &lt;/table&gt;
  
  &lt;div id="feedbackdiv" style="clear: both; padding-left: 15px; padding-right: 15px; display: none; margin-top: 20px;"&gt;
    &lt;p id="feedback" style="margin-top: 15px;"&gt;&amp;nbsp;&lt;/p&gt;
  &lt;/div&gt;
  &lt;p style="margin-top: 20px;"&gt;
    &lt;button class="btn btn-secondary" id="checkbutton" onclick="checkAnswers()"&gt;Check answers&lt;/button&gt;
  &lt;/p&gt;
  &lt;p id="retrybutton" style="display: none"&gt;
    &lt;button onclick="window.location.reload();" class="btn btn-secondary"&gt;Retry&lt;/button&gt;
  &lt;/p&gt;
  &lt;p id="solution" style="margin-top: 20px;"&gt;
    &lt;button class="btn btn-secondary" id="solutionbutton" onclick="showSolution()"&gt;Show solution&lt;/button&gt;
  &lt;/p&gt;</code></pre>
  </div>
  </div>
  </p>