I can't understand this challenge?

Tell us what’s happening:
I am confused of the instructions they had given there. But there are no hints of how to solve it…

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) {


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/84.0.4147.105 Safari/537.36.

Challenge: Record Collection

Link to the challenge:

Hello there,

I am not sure what you mean; this is one of the most hint-giving lessons in the curriculum. There are these hints below the instructions:

Hints
Use bracket notation when accessing object properties with variables.

Push is an array method you can read about on Mozilla Developer Network.

You may refer back to Manipulating Complex Objects Introducing JavaScript Object Notation (JSON) for a refresher.

And there are these hints, when you click Get Help → Get a Hint:

Hint 1
Use an else if statement to check the needed steps.

Hint 2
The second step listed in the instructions should be first in your else if statement.

Hint 3
To access the value of a key in this object, you will use collection[id][prop] .


We are happy to help, but it would help us help you, if you were specific about what is confusing.

2 Likes

Can you tell me what’s wrong in there?

I suggest you do some debugging, by placing this in your script:

console.log(updateRecord(5439, "artist", "ABBA"));

As well as the other failed test cases, and see what is happening.

Think about what you are doing in this line:

collection.push(value);

For future posts, please include the code correctly formatted, and not a screenshot of code. Screenshots are difficult to work with, and you are much less likely to get help, with them.

2 Likes