Still something left(dont know what)

I think i’ve done everything right

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")
{
if(!collection.hasOwnProperty("prop"))
{
collection[id][prop]=[];
collection[id][prop].push(value);
}
}
else if(prop=="tracks" && value!="")
collection[id][prop].push(value);

else if(value=="")

delete collection[id][prop];


return collection;
}

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

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 6.1; ) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.129 Safari/537.36.

Challenge: Record Collection

Link to the challenge:

1: There is no just if statement in an else if
2: An else if statement does end with else
3: I also think you misunderstood a huge part of what it is you need to do excatly
try to sketch out and take it step by step :3

1 Like

so, why are you checking for a property called prop?

hi ,
i guess what iam doing is first checking whether prop==tracks or not
if yes then checking whether collection.id has property tracks or not if yes then whole if equation become false and nothing happened but if hasownpropert gives false then equation become true and follwing if executes.

you are using the string "prop", not a variable
also, you want to check the whole collection object, or the nested object?
you are checking if collection has a variable named "prop", it doesn’t, as the property names of collection are numbers

Thanks, I got your point.