Basic JS, Record Collection problem

Hello, I’ve written this bit of code and can’t figure out why it isn’t working properly:

function updateRecords(id, prop, value) {
	if (value == "") {
	delete collection[id][prop];
	} 
  else { 
    if (prop = "tracks") {
		  if (collection[id].hasOwnProperty("tracks") == false) {
			collection[id][prop] = new Array();
			collection[id][prop].push(value);
			} else {
      collection[id][prop].push(value);
			}
		} else {
      collection[id][prop] = value;
		}
	}
  return collection;

In particular the last line collection[id][prop] = value it’s working just fine in isolation but not inside this setup.
Can anybody tell me why this is?
Thank you.

The whole thing is failing from one TEENY TINY problem. Just one. It’s in the following line. Can you spot it?

Remember to use a equality comparison ( == or === ) and not an assignment ( = )

2 Likes