In JavaScript, array indices start at 0, and an array's .length property will be one higher than the current highest element index. So for your array with four contiguous elements the .length will be 4 and the element indices are 0, 1, 2 and 3.
You need to set up your loop to run from 0 to .length - 1, so use i < myArray.length rather than i <= myArray[i].toString ().length:
for (var i = 0; i < myArray.length; i++)
The reason you though your code was working other than that error is that because you had i <= myArray[i].toString ().length it was testing i against the length of the toString() values of elements in the array rather than against the length of the array itself. So on the first iteration when i was 0 it would test if 0 is less than or equal to the length of the first element in the array, on the second iteration it tests if i is less than the length of the second element, and so forth. Because all items in your array had a .toString().length greater than the length of the array itself your loop did iterate through all of the elements, but then when i got to 4 it tried to test an element that didn't exist.