function updateRecords(id, prop, value) {
if (prop === "tracks" && value !== "") {
if(collection[id][prop]) //----------------------------------------> I didn't get this part, coz i thought If statements have some sort of conditions for it to execute but this lines doesnt seem to have any condition oon it. Can somebody explain it further? Thanks! :)
{
collection[id][prop].push(value);
}
else {
collection[id][prop]=[value];
}
} else if (value !== "") {
collection[id][prop] = value;
} else {
delete collection[id][prop];
}
return collection;
}
Do you remember the falsy bouncer challenge?
It is used in the same way, if collection[id][prop]
is falsy (undefined) it will not be executed, if it has a value (a string is truthy) it will be executed
in short, you are evaluating that statement to a boolean so the one you have is a going to be
collection[id][pro]] = true
if you had
!collection[id][prop]
then that would execute if it was FLASE