How to number arrays? Why doesn't this code work?
<p>This is my JavaScript code:</p>

<pre><code>Array.prototype.number = function () {
    var tempNum = this;
    for (i in this) {
        tempNum[i] = tempNum[(i + 1)] + ". " + tempNum[i]
    }
    return tempNum;
}
</code></pre>

<p>What I am trying to do is simple: number each item in an Array.</p>

<p>So I want to do this:</p>

<pre><code>["hello", "hi", "hey"].number()
 &gt; ["1. hello", "2. hi", "3. hey"]
</code></pre>

<p>But instead I get this:</p>

<pre><code>["hello", "hi", "hey"].number()
 &gt; ["undefined. hello", "undefined. hi", "undefined. hey"]
</code></pre>

<p>Why? How should I implement this and why is my code not working?</p>

<p>Thanks in advance!</p>
