title: Can local javascript variables be read by user console?
body: <p>I am trying to create an online lottery system in which user has to guess a number between 1 to 10. If the number matches with the javascript generate random number he will win the lottery. The method I used is:  </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(){
    var x = Math.floor((Math.random() * 10));
    var btn = document.getElementById("btn");
    btn.addEventListener("click", function(){
      var user_input = document.getElementById("text").value;
      if( user_input == x) {
        alert("Won Lottery", user_input, x);
      }
      else {
        alert(user_input + x + "sorry");
      }
    });
  }();</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;h2&gt;Guess a number between 1 and 10 &lt;/h2&gt;  
  &lt;input id="text" type="text"&gt;
  &lt;button id="btn" type="submit"&gt;Submit&lt;/button&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>My question is, can a hacker open the js console and somehow find the value of local <code>x</code> variable?</p>