Hi there,
i having a hard time in completing this challange, i,ve watched 3 videos but it looks like the statements that i have are not the same for the guys explaining on videos., i get everything else but this one " After updateRecords(5439, "tracks", "Take a Chance on Me") , tracks should have "Take a Chance on Me" as the last element."
can anybody help me understand? thanks in advance i really appreciate it.
If you share your code we can help you debug it.
Here it is:
https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/basic-javascript/record-collection… just in case will paste the code directly too below:
// Setup
var collection = {
2548: {
album: "Slippery When Wet",
artist: "Bon Jovi",
tracks: [
"Let It Rock",
"You Give Love a Bad Name"
]
},
2468: {
album: "1999",
artist: "Prince",
tracks: [
"1999",
"Little Red Corvette"
]
},
1245: {
artist: "Robert Palmer",
tracks: [ ]
},
5439: {
album: "ABBA Gold"
}
};
// Only change code below this line
function updateRecords(id, prop, value) {
if (prop != “tracks” && value != “”){
collection[id][prop] = value;
} else if (value === “”){
delete collection[id][prop];
}else if (prop === “tracks”){
collection[id][prop].push(value);
}
return collection;
}
updateRecords(5439, “artist”, “ABBA”);
It looks like you aren’t handling the case when there is not a tracks property yet correctly. You should make sure that you create an array of tracks correctly in that case.