title: How do I compare two variables containing strings in JavaScript?
body: <p>I want compare two variables, that are strings, but I am getting an error.</p>
  
  <pre class="lang-js prettyprint-override"><code>&lt;script&gt;
      var to_check=$(this).val();
      var cur_string=$("#0").text();
      var to_chk = "that";
      var cur_str= "that";
  
      if(to_chk==cur_str){
          alert("both are equal");
          $("#0").attr("class","correct");    
      } else {
          alert("both are not equal");
          $("#0").attr("class","incorrect");
      }
  &lt;/script&gt;
  </code></pre>
  
  <p>Is something wrong with my if statement?</p>