i will be so happy if I find this. I know ive been working on this one problem for too many days now lol
Asta la Vista babyyyyyyy
Ha ha Thanks Jeremy and ieahleen!!
but yea jeremy I picked up on what you were saying. the condition was not being ran because of the condition prior to it, if that makes sense. I am very happy I got pass this one, and I learn on this, thanks yall!
Nice work!
You can significantly simplify your code with this reordering, as a fun bonus
function updateRecords(records, id, prop, value) {
if (value === "") {
delete records[id][prop];
return records;
}
if (prop !== "tracks") { // We already know value is not ""
records[id][prop] = value;
return records;
}
if (records[id].hasOwnProperty("tracks") === false) { // We already know prop is not "tracks"
records[id][prop] = [value];
return records;
}
if (records[id].hasOwnProperty("tracks") === true) { // We already know prop is not "tracks"
records[id][prop].push(value);
return records;
}
}
More simplification along those lines is also possible Generally, if you see repetition, it is an opportunity for simplification.
and yes totally agree with simplifying whenever possible especially when you see repetition because that is a sign that code can be written more concise. I really appreciate the help! Cheers
This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.