Tell us what’s happening:
Describe your issue in detail here.
How do I get prop, which is not defined in the object, to either pick “artist” or “tracks” keys ?
Please take a look at my code below to see if that’s the problem. The function works fine when the entry is: updateRecords(recordCollection, 2468, "tracks", "Free")
**Your code so far**
// 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) {
if (prop !== id.tracks && value !== "") {
prop = value
} else if (prop === id.tracks && id.tracks == undefined) {
return [id.value]
} else if (prop == tracks && id.value !== "") {
id.tracks.push('value')
} else if (id.value === "") {
delete id.prop
}
return records;
}
//updateRecords(recordCollection, 5439, 'artist', 'ABBA');
console.log(updateRecords(recordCollection, 5439, "artist", "ABBA"))
**Your browser information:**
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:92.0) Gecko/20100101 Firefox/92.0
Challenge: Record Collection
Link to the challenge: