Can't solve: Record Collection

Tell us what’s happening:

I’m trying to solve it but, all my attemps at it are in vain.

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: [
     "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" && collection.album !== collection.album ){
create = [];
collection[id][prop] + create;
}if else (prop === "tracks" && value !== ""){
collection[prop].push(value); //prop contains tracks 
}else (value == "")
delete collection[prop];
} }
return collection;

updateRecords(5439, "artist", "ABBA");

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36.

Challenge: Record Collection

Link to the challenge:

collection.album !== collection.album

why this? it doesn’t make sense. First because you are checking if something is different from itself (always false), and second because collection.album is undefined

collection[id][prop] + create

one, the result is not assigned to anything
two, you can’t use + with arrays.

then, if else is not a thing: it’s else if

collection[prop] is undefined, as collection has numbers as property names. You need to use id somewhere to access the inner objects.

Your return collection is also outside of function body, so that is also an error.

try one thing at a time.
first, this:

Your function must always return the entire collection object.
the first thing in the challenge description is

then try to implement this, which is the first thing in the challenge description:

If prop isn’t "tracks" and value isn’t empty ( "" ), update or set the value for that record album’s property.

delete everything else in the function body and try to implement just this. You can pretty much follow what’s written.

after that, share with us, and then try the following paragraph.

1 Like