Record Collection weird thing going on

Tell us what’s happening:
Hey been working on the record collection challenge getting used to using objects took a little while to get close to working mainly screwing up by using dot notation instead of brackets the hint should of helped but i saw the inputs of the function as paramenters and not veriables so thats on me lol anyway my code is working getting all but one right but im a little lost to why the last one doesnt pass cause another with the extact same criteria seems to pass no album.
After updateRecords(5439, "tracks", "Take a Chance on Me") , tracks should have "Take a Chance on Me" as the last element.
however this does PASS
After updateRecords(1245, "tracks", "Addicted to Love") , tracks should have "Addicted to Love" as the last element.

the error msg is: collection[id].tracks is undefined

i cant see that in my code tho lol maybe im being blind it actually happerns with me a sometimes just cant see something right infront of me any help appreachted
Your code so far
function updateRecords(id, prop, value) {

if (prop == “artist” && value != “”){
collection[id][“artist”] = value;
if (prop != “tracks” && value != “”){
collection[id][“album”] = value;
if ( prop === “tracks” && value !=""){
else if (value == “”){
delete collection[id][prop];

return collection;

Link to the challenge:

had another look figured out the issue was needing to check for an array tracks and if its not there create an array on one line and then push on the next line

if ( prop === “tracks” && value !=""){
if (collection[id].hasOwnProperty(“tracks”)){
} else {
collection[id][“tracks”] = [];

1 Like