Two issues with "Record Collection"

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;
}

`

I reset my code on the site and copied in yours. It worked straight away. Maybe you accidentally edited something out, but I’m seeing var collectionCopy = JSON.parse(JSON.stringify(collection));

1 Like

Thanks. I think you’re right, I must have changed something unknowingly. I reset my code, copied my function in, and it works. At least I learned a new debugging thing to try.