Tell us what’s happening:
After `updateRecords(5439, "tracks", "Take a Chance on Me")` , `tracks` should have `"Take a Chance on Me"` as the last element.
After `updateRecords(1245, "tracks", "Addicted to Love")` , `tracks` should have `"Addicted to Love"` as the last element.
After `updateRecords(2468, "tracks", "Free")` , `tracks` should have `"1999"` as the first element.
Is this because I am not checking for new objects ?
Your code so far
function updateRecords(id, prop, value) {
if (value == "") {
delete collection[id][prop];
return collection;
}
if (prop != "tracks") {
collection[id][prop] = value;
if (collection[id][prop]) {
collection[id][prop] = value;
} else {
collection[id][prop].push(value);
}
return collection;
}
};
Your browser information:
User Agent is: Mozilla/5.0 (X11; CrOS x86_64 12105.47.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.54 Safari/537.36
.
Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-javascript/record-collectionThis text will be blurred