Tell us what’s happening:
Every test I have keeps failing on the record collection challenge. I went as far as the hint page and even copied the solution and everything is failing. I have finished other challenges before and after and this is the only one giving me issues. What in the world am I missing?
**Your code so far**
// 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 (prop === "tracks" && !collection[id].hasOwnProperty("tracks")){
collection[id][prop] =[];
}
else if (prop === "tracks" && value != ""){
collection[id][prop].push(value);
}
else if(value === ""){
delete collection[id][prop];
}
return collection;
}
**Your browser information:**
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.82 Safari/537.36
So I tried that and I tried copying the entire solution, even the setup code, and everything fails. I have completed the challenges after this one as well and this is the only one not passing for me.
You changed the function signature. I’d imagine that you looked at old solutions and tried to replicate them.
The challenges get updates from time to time, so trying to replicate the old solutions of others will sometimes lead you astray. This one was changed a fairly long time ago.
I’d reset the challenge and use the correct function signature.
Here is the correct function signature
function updateRecords(records, id, prop, value) {
This is the base code when I ‘Reset All Code’. The function signature only contains (id, prop, value). I have tried my own solution which I had working in my editor, I have tried the solution on FreeCodeCamp and I have also tried solutions I have found elsewhere. This is the only challenge that I’m having issues with. I understand the logic of the program as well.
// 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) {
return collection;
}
updateRecords(5439, "artist", "ABBA");