用JavaScript更新记录

The goal is to update the record with new data . But am getting id not defined . The goal is to update the record with new data . But am getting id not definedCode I tried to run

var collectionCopy =
  JSON.parse(JSON.stringify(myMusik));

function updateRecords(id, prop, value) {
  if (value === "") {
    delete myMusik[id][prop];
  } else if (prop == "award") {
    myMusik[id].
      [prop] = myMusik[id][prop];
    myMusik[id][prop].push(value);
  } else if (prop == "artist") {
    myMusik[id][prop] = myMusik[id][prop];

  } else if (prop == "platform") {
    myMusik[id][prop] = myMusik[id][prop] || [];
    myMusik[id][prop].push(value);
  } else {
    myMusik[id][prop] = value;
  };
  return myMusik;
};


updateRecords(2515, "artist", "Kiss Daniel");
updateRecords(2515, "release_year", 2019);
updateRecords(2515, "award", "1");
console.log(updateRecords(2515, "title", "Jaho"));
评论