i use this function to complete the first task
function updateRecords(records, id, prop, value) {
if(prop !== “tracks” && value !== “”){records[id][prop]=value;}
return records.[id];
}
everything must work fine as i already check the output with
console.log(updateRecords(recordCollection, 5439, ‘artist’, ‘ABBA’));
it gives this updated data as an output.
{ albumTitle: ‘ABBA Gold’, artist: ‘ABBA’ }
the result is correct as they ask for
" After updateRecords(recordCollection, 5439, "artist", "ABBA")
,artist
should be the string ABBA
" but i still cant pass the first task, can anyone tell me why?
thank you in advance.
**Your code so far**
// Setup
const 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 !== "tracks" && value !== ""){records[id][prop]=value;}
return records[id];
}
console.log(updateRecords(recordCollection, 5439, 'artist', 'ABBA'));
Challenge: Record Collection
Link to the challenge: