TypeError: Cannot set property '0' of undefined
<pre><code>var fields = ['firstName', 'lastName', 'address', 'postCode', 'email', 'phone', 'dob'];
    for (var i=0; i&lt;fields.length; i++) {
            if (!$('#'+fields[i]).val()) {
                alert('The ' + getFieldTitle(fields[i]) + ' field is required.');


                return false;
            }
            values.fields[i] = $('#'+fields[i]).val();
            console.log($('#'+fields[i]).val() , values , fields[i]);
        }
</code></pre>

<p>Values is defined as a global variable at the beginning of the script. It seems that on the first iteration of assigning the proper name to the array position I get a failure. What i log the field names they appear to show up correctly but they don't get assigned to the array values properly?</p>

<p>EDIT: Left out the fields initialization at first, sorry about that</p>
