Hi guys, i have been write some code for the challenge
This is the code
// 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) {
var myCol = collection[id];
if(prop == "tracks") {
if(myCol.hasOwnProperty(prop)) {
if(value != "") {
myCol[prop].push(value);
}else {
console.log(id);
console.log(value == "");
console.log("Prop '" + prop + "' has been deleted");
console.log("But why the test is wrong ??");
delete myCol[prop];
}
}else {
myCol[prop] = [];
myCol[prop].push(value);
}
}else {
if(value != "") {
myCol[prop] = value;
}else {
delete myCol[prop];
}
}
// collection = myCol;
return collection;
}
console.log(updateRecords(2548, "tracks", ""));
but just the test updateRecords(2548, “tracks”, “”) always error
i have done delete prop tracks but why is not pas ?
this is the image