Dear Campers,
I could use a bit of feedback on getting started on this assignment. Here 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) {
if (collection[prop] == "tracks" && collection[value] != "") {
collection[id][prop].push(value);
} else if (collection[prop] != "tracks") {
collection[id][prop] = value;
} else if (collection[id][prop] != "album") {
collection[id][prop] = value;
} else {delete collection.value};
console.log(collection)
return collection;
}
updateRecords(5439, "artist", "ABBA");
Iām not sure if Iām starting my āelse ifā statement correctly. The instructions says:
If prop
is "tracks"
and value
isnāt empty ( ""
), push the value
onto the end of the albumās existing tracks
array.
I followed accordingly and coded thus.
I appreciate any constructive feedback. Thanks , Campers. Please feel free to ask me anything regarding my code so far.