Record Collection Final Test help

Hello everyone. For the record collection challenge, I have passed all of the tests except the final one. The test says that the track should not be set, however, what should be returned? I have tried returning the entire object, the specific array which should not be altered, and the entire 2548 property. What am I missing?

Can you copy-paste your code?

it helps if you can post some code - perhaps a link to the challenge - it says…

If value is empty (""), delete the given prop property from the album.

it wants the whole object returned
maybe this link will help https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/delete

Sure. Here’s a link to the challenge, and my code:

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

i believe with that last test - you would hit this section of code…

    } else {
      collection[id][prop].push(value);
      return collection;
    }

and return the object there - and never reach the delete
put some console.logs in there to find out

@moT01 is correct above the else code executes and the delete never happens.

In all cases, collection should be returned. You could factor out all of the return collection lines out of the if-else branches and put just one of it at the end of the function.

What you do with the collection (the logic in the function) is what’s important.

Thanks for your help, @moT01 right, as the else was preventing the deletion of the object. Based off @kevcomedia’s suggestion, I put the return collection outside of the if else statements.