Basic JavaScript - Record Collection

I have completed the record collection challenge but there is a question if i write:

records.id.prop=value; //line 1
records.id.prop.push(value); //line 2

the challenge is not passed but when i write:

records[id][prop]=value; //line 3
records[id][prop].push(value); //line 4

the challenge is passed.
whats the difference between line1 and line3 and line2 and line4?

You can only use dot notation with the exact literal name of a property. If you have the property name in a variable, bracket notation is mandatory.

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.