title: Please help me with this simple script
body: <p>I have just started to learn native javascript and I am trying to write a simple script which will display an alert window showing the text contained in each <code>&lt;p&gt;&lt;/p&gt;</code> element.</p>
  
  <p>I am posting the code below. Please let me know what I am doing wrong</p>
  
  <pre><code>function show(){
    var x = document.getElementsByTagName('p');
    for(i=0;i&lt;x.length;i++) {
      x[i].onclick=function(){
        alert(x[i].innerText);
      }
    }
  }
  
  show()
  </code></pre>
  
  <p>HTML is below:</p>
  
  <pre><code>&lt;p&gt;Blackberry&lt;/p&gt;
  &lt;p&gt;Strawberry&lt;/p&gt;
  &lt;p&gt;Raspberry&lt;/p&gt;
  </code></pre>