Challenge: Record Collection

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:

the first thing on the list is “Your function must always return the entire record collection object.”. check what you are returning.

1 Like

Your function “must always return the entire record collection object” - you are returning only the record you have updated.

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