Hey folks, running into an issue with this. Line 25 ( records.id.prop = value; )is throwing an ‘Uncaught TypeError: cannot set property ‘prop’ of undefined’ error in both FCC and Codepen.
What am I doing wrong?
In the example below I’ve stripped away everything except the line that’s causing the issue. I think there’s a fault with how I’m trying to create and assign the new property in the recordCollection/record object.
// Setup
var recordCollection = {
2548: {
albumTitle: 'Slippery When Wet',
artist: 'Bon Jovi',
tracks: ['Let It Rock', 'You Give Love a Bad Name']
},
2468: {
albumTitle: '1999',
artist: 'Prince',
tracks: ['1999', 'Little Red Corvette']
},
1245: {
artist: 'Robert Palmer',
tracks: []
},
5439: {
albumTitle: 'ABBA Gold'
}
};
// Only change code below this line
function updateRecords(records, id, prop, value) {
records.id.prop = value;
}
recordCollection = updateRecords(recordCollection, 5439, 'artist', 'ABBA');