Record Collection:
please can you help me what is wrong in this code:
function updateRecords(id, prop, value) {
if (value !== "") {
if (prop !== "tracks") {
collection[id][prop] = value;
} else {
if (!collection[id].hasOwnProperty("tracks")) {
collection[id][prop] = [];
collection[id][prop].push(value);
} else {
collection[id][prop].push(value);
}
}
} else {
delete collection[id][prop];
}
return collection;
}
What do the failing tests say?
// running tests
collectionCopy is not defined
// tests completed
Did you modify anything outside of the updateRecords
function?
no here it is
updateRecords(5439, "artist", "ABBA");
The code work well in chrome console;
Try clearing the solution and making sure that you only modify the contents of the updateRecords
definition.
Hello the same thing happening
// running tests
collectionCopy is not defined
// tests completed
Are you absolutely sure that you didn’t touch this line?
// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));
I did not see it in my code where to paste it please??
Hello thank you I paste it in the head of my function and it works
That line was already there. You must have deleted it. That’s why I suggested that you completely reset the challenge to and be careful to only change what is inside of the function definition.
Thank you Sir