Help! Java Script - Record Collection

I’m trying to solve this example. I even used ‘Get a Hint’ but I still have problem running it. The test result says:
After updateRecords(collection, 2468, “tracks”, “Free”), tracks should have the string 1999 as the first element.
After updateRecords(collection, 2548, “tracks”, “”), tracks should not be set.

This is my code:

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

updateRecords(collection, 5439, 'artist', 'ABBA');

Thanks for your help!

  **Your browser information:**

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

Challenge: Record Collection

Link to the challenge:

this is always false, so when prop === "tracks" is true what happens is always

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 (’).

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