What am I doing wrong here? Record Collection

Tell us what’s happening:
My code runs as described in the dev tools console but keeps failing on the platform… What I am doing or not doing?

  **Your code so far**
function updateRecords(records, id,prop,value) {
   switch(id) {
    case 2548 :
      records = recordCollection[2548];
      break;
    case 2468:
      records = recordCollection[2468];
      break;
    case 1245:
      records = recordCollection[1245];
      break;
    case 5439:
      records = recordCollection[5439];
      break;
    default:
      return "Record does not exist";
  };

  if (prop != "tracks" && value != ""){
    records[prop] = value;
  }else if (prop === "tracks"){
      records.tracks = [];
      records.tracks.push(value);
  }else if (prop === "tracks" && value != ""){
      records.tracks.push(value);
  }else if (value == ""){
    delete records['artist'];
  }
  return records;
}

  **Your browser information:**

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

Challenge: Record Collection

Link to the challenge:

You should not use the global variable at all.

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