title: JavaScript : switch and check radio button
body: <p>I wrote this code to switch between radio buttons and show my custom alert.</p>
  
  <pre><code>&lt;script&gt;
      function test() {
              if (radio[0].checked = true) {
                  alert("hello1");
              }
  
              if (radio[1].checked = true) {
                  alert("hello2");
              }
      }
  &lt;/script&gt;
  
  
  &lt;input type="radio" onclick="test()" value="0"&gt;
  &lt;input type="radio" onclick="test()" value="1"&gt;
  </code></pre>
  
  <p>When check any of radio buttons it must show specific alert.
  What is wrong?</p>