Record Collection help kuba

Someone can tell why it doesn’t work though it works in Visual Studio Code?

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

You should start your own thread @kuba01136

  • The recordCollection object is passed to the updateRecords function using the records parameter. Use the records parameter not the top-level object.

  • The condition if (value == "") doesn’t depend on any other condition, as such it can be moved to the top of the function and you can return the object after the delete.

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