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.
DOES NOT PASS
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 !=""){
collection[id][“tracks”].push(value)
}
else if (value == “”){
delete collection[id][prop];
}
return collection;
}
\\
Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-javascript/record-collection