Record Collection Problem!

What am I doing wrong here?

Link to the Challenge is here

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

  return collection;
}

I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (’).


Please, next time, if you have a question about a specific challenge as it relates to your written code for that challenge, just click the Ask for Help button located on the challenge. It will create a new topic with all code you have written and include a link to the challenge also. You will still be able to ask any questions in the post before submitting it to the forum.

Thank you.

collection[id] doesn’t have a property called "prop"

please review how to access object properties using variables

2 Likes

Okay Thank you for the help ! :slight_smile: