title: store variable value inside a if statement
body: <p>1st if condition:</p>
  
  <pre><code>if (currentQuestionIndex == 2) {
      var xvalue = currentscore;
  }
  </code></pre>
  
  <p>2nd if condition: (<strong>note:</strong> current score increments for every <code>currentQuestionIndex</code>)</p>
  
  <pre><code>if (currentQuestionIndex == 5 &amp;&amp; currentscore ==xvalue) {
      console.log('thanks for your participation')
  }
  </code></pre>
  
  <p>I want to access the value of <code>xvalue</code> in 1st if condition and reference it in 2nd if condition. Is there any way to store value of a variable and reference it later without regards to if condition</p>