title: Global variable in jquery not giving output
body: <p>I need to declare value in global variable that I pull from data attribute. But on test script I am able to print on console but when I use it on page its giving undefined in console. Here is the jquery script I came up with.</p>
  
  <pre><code>var PClevel;
  $(document).ready(function() {
  var array = [];
  $(".proimg").slice(0,3).each(function() {
      array.push($(this).data("pid"));
      PClevel = ("["+array.join(",")+"]");
  });
  });
  console.log(PClevel);
  </code></pre>
  
  <p><a href="https://jsfiddle.net/wq3tqkzo/" rel="nofollow noreferrer">https://jsfiddle.net/wq3tqkzo/</a></p>
  
  <p>Can anyone advise please why its not printing the output on live page. I have jquery library available on it. Or can anyone advise if I can have similar function in pure javascript.</p>