Beginner - "NaN" Error When Using the Following While Loop

Budding Javascript learner here and I am trying to get through some Nodejs tutorials. One of the tutorials has me looping through an array that always begins with two non numbers and then numbers following on from there so I am using: array[2] as a starting point.

var arrayLength = (process.argv.length);
var i = 2;
var y = 0;

while (i <= arrayLength) {
    y = y + Number(process.argv[i]);
    i++;
}

Example array [ 'node', '/path/to/your/program.js', '1', '2', '3' ]

However the variable y ends up being equal to NaN. Which, at my early stage of learning, I understand means a number tried to have a string added to it, which of course can't mathematically be done.

When I did some debugging, I found that the second to last time the while() is ran, it becomes NaN.

I'm scratching my head here on why. Any pointers?

You are running the loop one iteration too far. Change:

i <= arrayLength

to

i < arrayLength

(Since i starts at 0 and not 1, you only want to interate until i is one less than the length.)