title: Javascript html dom elements array for in loop
body: <p>So let's say I have an array of DOM elements:</p>
  
  <pre><code>var z = document.getElementsByClassName('name');
  </code></pre>
  
  <p>and for each element I want to set attribute with for in loop:</p>
  
  <pre><code>for(var n in z){z[n].setAttribute('marked', '1');}
  </code></pre>
  
  <p>For above code I get <code>z[n].setAttibute is not a function</code>. However when I manually check in console elements of z array, <code>marked</code> attribute has been added to each element. Why is that happening and how can I prevent such error from happening?</p>