Hi, i’m currently on challenge 211 : Record Collection Challenge.
After updateRecords(2468, “tracks”, “Free”), tracks should have “1999” as the first element.
This is the only condition that i failed.
i confused because i managed to fulfill the condition and still failed.
collection =
{
“1245”: {
“artist”: “Robert Palmer”,
“tracks”: []
},
“2468”: {
“album”: “1999”,
“artist”: “Prince”,
“tracks”: [
“1999”,
“Little Red Corvette”
]
},
“2548”: {
“album”: “Slippery When Wet”,
“artist”: “Bon Jovi”,
“tracks”: [
“Let It Rock”,
“You Give Love a Bad Name”
]
},
“5439”: {
“album”: “ABBA Gold”,
“artist”: “ABBA”
}
}
And this is my code:
function updateRecords(id, prop, value) {
if(value === “”){
delete collection[id][prop];
}else {
if(prop === "tracks"){
if(!collection.hasOwnProperty("tracks")){
collection[id][prop] = [ ];
collection[id][prop].push(value);
}
else {
collection[id][prop].push(value);
}
}else {
collection[id][prop] = value;
}
}
return collection;
}
Anyone can help me with this?
thank you really appreaciate it