Record Collection - Can't get past these 2 requirements

Tell us what’s happening:
Describe your issue in detail here.
Hello everyone,
Everytime I run the test for the Record Collection challenge, I keep not being able to get past these two requirements -

  1. After updateRecords (recordCollection, 2548, “artist”, " ") , artist should not be set.

  2. After updateRecords (recordCollection, 2548, “tracks”, " "), tracks should not be set.
    I think it’s possibly something to do with the 2nd condition where it says, “update or set that albums prop to value”, but am still stuck on how I fixed this issue, so any hints or help would be greatly appreciated, as I have tried a couple of solutions that have not worked so far.

    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 !== 'tracks' && value !== " "){
  records[id][prop] = value;
 } else if(prop === 'tracks' && records[id].hasOwnProperty([prop]) === false) {
    records[id][prop] = [value];
} else if(prop === 'tracks' && value !== " "){
      records[id][prop].push(value);
    }else if (value === ""){
      delete records[id][prop];
    }

return records;
}

updateRecords(recordCollection, 5439, 'artist', 'ABBA');
  **Your browser information:**

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.131 Safari/537.36

Challenge: Record Collection

Link to the challenge:

should be value !== "")

Thanks, so much for the solution, honestly I have been staring at this problem for days! :+1:

it works anyway because of inplicit type coercion, but you have two extra characters here

I was going to comment on that as well.

hasOwnProperty takes a String or Symbol as the argument, not an array. records[id].hasOwnProperty([prop]). Looking at the specs it seems it just gets converted to a string (ToPropertyKey).

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