I’ve been working on this challenge for a couple of days now and I can’t figure it out! I am passing every requirement except for “After updateRecords(5439, “tracks”, “Take a Chance on Me”), tracks should have “Take a Chance on Me” as the last element.”
Here’s my code so far:
function updateRecords(id, prop, value) {
if (value === “”){
delete collection [id][prop];
}else if(!collection[id].hasOwnProperty(prop)) {
collection[id][prop] = (value);
}else {
collection[id][prop].push(value);
}
return collection;
}
Any feedback is much appreciated! Thank you!
The tracks
property should be an array. Your code assigns a string to it instead.
hello friends, how are you?
i I’m fine and I am new at this
Thanks for your help! Do you mean I should put collection[id][prop] = [value];
instead?
When I try that it causes me to fail "After updateRecords(5439, “artist”, “ABBA”), artist should be “ABBA” condition with everything else checked and I don’t understand why.
tracks
is a special case among the possible prop
values, so consider doing something like this in your code
if (value === "") {
// ...
}
else if (prop == "tracks") {
// ...
}
else { // for the other `prop` values...
// ...
}