Compare Record Collection Answers FCC Basic Javascript

Hello everyone!

I just finished the Record Collection problem that’s presented during the Basic JavaScript section of FCC. I know there is often more than one solution in JavaScript, and that often each answer has it’s own set of pros and cons. But i also understand that some answers are better than others.

I was hoping to get some help with comparing my answer with the answer found in the FCC guide. I’d like to avoid developing any bad habits and learn how to code more wisely and efficiently. Unfortunately, due to me being so new to the forums, I can’t insert a link to the challenge. But hopefully it won’t be too difficult to find. Thanks in advance for everyone’s input!

FCC GUIDE ANSWER

function updateRecords(id, prop, value) {
  if (prop === "tracks" && value !== "") {
   if(collection[id][prop]) {
    collection[id][prop].push(value);
   }
   else {
    collection[id][prop]=[value];
   }
  } else if (value !== "") {
    collection[id][prop] = value;
  } else {
    delete collection[id][prop];
  }

  return collection;
}

MY ANSWER

function updateRecords(id, prop, value) {

  if (value == "") {
    delete collection[id][prop];
  } else if (prop == "tracks"){
    if (collection[id][prop] == undefined) {
      collection[id][prop] = [value];
    } else {
      collection[id][prop].push(value);
    }
  } else {
    collection[id][prop] = value;
  }
  
  
  return collection;
}
``