Tell us what’s happening:

Your code so far

// Setup
var collection = {
    "2548": {
      "album": "Slippery When Wet",
      "artist": "Bon Jovi",
      "tracks": [ 
        "Let It Rock", 
        "You Give Love a Bad Name" 
    "2468": {
      "album": "1999",
      "artist": "Prince",
      "tracks": [ 
        "Little Red Corvette" 
    "1245": {
      "artist": "Robert Palmer",
      "tracks": [ ]
    "5439": {
      "album": "ABBA Gold"
      "tracks": []
// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

// Only change code below this line
function updateRecords(id, prop, value) {
  if (prop == "tracks" && value !== ""){
    if(value !== ""){;
  } else{
  collection[id][prop] = [value];
  }else if( prop !== "tracks"){ = value;
  return collection;

// Alter values below to test your code
updateRecords(5439, "artist", "ABBA");

Your browser information:

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

Link to the challenge:

The following if statement is an example of what is wrong.


There is no such property named id, so is undefined and undefined does not have a prop property.

id and prop are variables, so how do you reference a variable as a property of an object? You have already learned how to do this and are also referencing the same two variables correctly in another location in your code.

okay, so I changed it to bracket notation, but i’m still not able to pass the test

What happens when you pass 5439 as a string?

updateRecords(5439, "artist", "ABBA");

Can we see your updated code, remember to use the code formatting when posting the code.

  1. If you correctly switched to bracket notation, then you are close, think about what needs to happen when:
"props" is not "tracks" and "value" is an empty string ""
  or else
  1. You seem to have changed the object. You have added a tracks property with an array, but forgotten a comma (which should cause the test not to run). You may just have been testing. However doing so actually lets you skip (you have not) making an array. Not sure why the test doesn’t check that the object wasn’t modified.
  1. nothing happens? because there isn’t any property(other than tracks) which has an empty string.
  2. I removed the tracks property I added, but it still isn’t working.

It returns a new value which was set for it?

I was referring to this test:

After updateRecords(2548, “artist”, “”), artist should not be set

Again it would be helpful to see your code.

1 Like