Basic JS| Record Collection|I don't know why my code does not pass the test?I will be grateful If you can help me

function updateRecords(records, id, prop, value) {
  
 const a = records[id].hasOwnProperty(prop);
  if(value === ""){
    delete records[id].prop;
  }else if(prop === "tracks" && a === false
  ){
   records[id].prop=[value];

  }else if(prop === "tracks" && a === true) {
    
    records[id].prop.push(value);
  }else if(prop !== "tracks"){
    records[id].prop=value;
  }
  return records;
}

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

https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/basic-javascript/record-collection

Welcome to the forum!

Please provide link to the task, and consider to format your code:

You can’t use dots here. You are dealing with variables, brackets needed

1 Like