title: Change Variable Value with Radio Buttons
body: <p>I want a variable (chanceoflive) to be <strong>stored with localStorage</strong>. Then, I have radio buttons. I want it so that depending on which radio button is selected, the variable chanceoflive will be changed. This is what I have:</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>var chanceoflive = 0;
  var user;
  function choose(choice){
      user = choice;
  }
  
  function changechanceoflive(){
      if (user == brick) {
          chanceoflive += 1;
      }
      else if (user == wood) {
          chanceoflive +=3
      }
      else if (user == stone) {
          chanceoflive +=2
      }
      localStorage.setItem("chanceoflive", chanceoflive);
  }
  
  function test(click){
      alert(chanceoflive);
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div id="radiobuttons" class="container" name="buttons" align=center&gt;
  
    &lt;h2&gt;I Want my Building to be Made of:&lt;/h2&gt;
  
    &lt;ul&gt;
      &lt;li&gt;
        &lt;input type="radio" id="brick-option" name="material" value="1" onClick="choose('Bricks')"&gt;
        &lt;label for="brick-option"&gt;Bricks&lt;/label&gt;
  
        &lt;div class="check"&gt;&lt;/div&gt;
      &lt;/li&gt;
  
      &lt;li&gt;
        &lt;input type="radio" id="wood-option" name="material" value="3" onClick="choose('Wood')"&gt;
        &lt;label for="wood-option"&gt;Wood&lt;/label&gt;
  
        &lt;div class="check"&gt;
          &lt;div class="inside"&gt;&lt;/div&gt;
        &lt;/div&gt;
      &lt;/li&gt;
  
      &lt;li&gt;
        &lt;input type="radio" id="stone-option" name="material" value="2" onClick="choose('Stone')"&gt;
        &lt;label for="stone-option"&gt;Stone&lt;/label&gt;
  
        &lt;div class="check"&gt;
          &lt;div class="inside"&gt;&lt;/div&gt;
        &lt;/div&gt;
      &lt;/li&gt;
    &lt;/ul&gt;
  &lt;/div&gt;
  
  &lt;form action="chooseheight.html"&gt;
    &lt;div class="wrapper"&gt;
      &lt;button class="button" onClick="test();changechanceoflive()" align=center&gt;Submit&lt;/button&gt;
    &lt;/div&gt;
  &lt;/form&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>Although, it always just alerts 0. Is it a problem with localStorage or something else?</p>