First, whenever I run the code I get an error: "reference error: stringify is not defined"
That’s on line 29, part of the code I’m not supposed to change, but I can comment it out and things run. I don’t know if commenting that out is a problem.
That code is var collectionCopy = JSON.parse(stringify(collection));
Second, I can pass all but the first test in the “Record Collection” challenge: ‘After updateRecords(5439, “artist”, “ABBA”), artist should be “ABBA”’
I read threads about this issue and looked at solutions posted here and elsewhere that were said to work and have not found the issue with my code. I even copied and pasted a couple solutions that other said worked, and they didn’t pass the first test. Here’s my code, I believe the line collection[id][prop] = value;
should address the test I’m failing, but I don’t know what’s wrong with that line.
function updateRecords(id, prop, value) {
if (value === "") {
delete collection[id][prop];
}
else if (prop === "tracks") {
if(collection[id].hasOwnProperty('tracks')) {
collection[id].tracks.push(value);
}
else {
collection[id].tracks = [];
collection[id].tracks.push(value);
}
}
else {
collection[id][prop] = value;
}
return collection;
}
`