title: How to compare two variables in javascript
body: <p>I want to match two variables.</p>
  
  <pre><code>var this_roll;
  </code></pre>
  
  <p>and</p>
  
  <pre><code>var last_roll;
  </code></pre>
  
  <p>I have this code, that i want the output of "win" or "losse". The output should be "win" if <code>last_roll</code> and <code>this_roll</code> have the same value and "lose" if not</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>"use strict";
  var x;
  var win_losse = 'losse';
  var last_roll;
  var last_bet;
  var this_roll = $('#past')[0].childNodes[9].textContent;
  var bet_input = document.getElementById('betAmount').value=x;
  var roll_time = $('#banner')[0].childNodes[0].textContent;
  var base_bet = 5;
  
  function thisRoll() {
  
   console.log(this_roll);
   if (this_roll == 0) {
    this_roll = 'green';
   } else if ((this_roll &gt;= 1) &amp;&amp; (this_roll &lt;= 7)) {
    this_roll = 'red';
   } else if ((this_roll &gt;= 8) &amp;&amp; (this_roll &lt;= 14)) {
    this_roll = 'black';
   }
  }
  
  function compare() {
  
   if (this_roll == last_roll) {
    win_losse = 'win';
   } else {
    win_losse = 'losse';
   }
   console.log(win_lose);
  }
  
  function lastRoll() {
  
   console.log(this_roll);
   if (this_roll == 0) {
    last_roll = 'green';
   } else if ((this_roll &gt;= 1) &amp;&amp; (this_roll &lt;= 7)) {
    last_roll = 'red';
   } else if ((this_roll &gt;= 8) &amp;&amp; (this_roll &lt;= 14)) {
    last_roll = 'black';
   }
  }
  
  function bet() {
  
   if (win_losse == 'win') {
    x = base_bet;
   } else if (win_losse == 'losse') {
    x = last_bet * 2;
   }
  }
  console.log(x);</code></pre>
  </div>
  </div>
  </p>