Record Collection Problem Unsolved

I don’t understand why I’m failing this one. It keeps on saying
After updateRecords(collection, 2548, "artist", "") , artist should not be set.
After updateRecords(collection, 2548, "tracks", "") , tracks should not be set.

Even though I think that should be solved by the last (else if) already. Please help me.

// Setup
var collection = {
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
var collectionCopy = JSON.parse(JSON.stringify(collection));

function updateRecords(collection,id, prop, value) {
 if (prop !== "tracks" && value!== " "){
  collection[id][prop] = value;
 else if (prop === "tracks" && collection[id].hasOwnProperty([prop])){
 else if (prop === "tracks" && !collection[id].hasOwnProperty([prop])){
else if (value === " "){
  delete collection[id][prop];
return collection;


updateRecords(collection, 2548, "artist", "");
  **Your browser information:**

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

Challenge: Record Collection

Link to the challenge:

You are not always including this check. What happens if you move your last if-else clause to be the first thing you check?

I tried exchanging that (value=" “) with the first if-else, a while ago and it didnt work.
Not i tried (!value”) then set it first and it’s okay now. Thanks a lot.

1 Like

this is an empty string

and with this, the check passes, as "" !== " " is true

1 Like

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