Java Script lesson 91 record collection

Please forgive me I’m a newbie…

I don’t know if it’s me or is this challenge written in a way where it’s hard to interpret what 's been asked. I’m not understanding. Is it’s asking to update the VAR COLLECTION, because it ask to update or set the value for that record album’s property.
Isn’t the album property album, artist and tracks?

See below…

Write a function which takes an album’s id (like 2548 ), a property prop (like "artist" or "tracks" ), and a value (like "Addicted to Love" ) to modify the data in this collection.

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

The code below is from the hint. I have been practicing with it. I’m stuck here trying to get a better understanding. I don’t want to move on until I do. I have been working on it for a while. I understand what the code is doing, but I don’t understand some of the wording.

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].push(value);
 }
 else {
  collection[id][prop]=[value];

} else if (value !== "") {
  collection[id][prop] = value;
} else {
  delete collection[id][prop];


return collection;
}

// Alter values below to test your code
updateRecords(5439, "artist", "ABBA");

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:73.0) Gecko/20100101 Firefox/73.0.

Challenge: Record Collection

Link to the challenge:
https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/basic-javascript/record-collection

this is one album object situated in the collection object

the function receive one id to identify which album object the function have to update, one prop to identify which property has to be updated, and one value that is the new value or the value to be added (if you need to update the tracks property)

collection is getting updated because its contents are changing.
collection is an object. Its properties are id numbers. The value of each of those properties is an object (an “album”). It can have the properties album (string), artist (string) and tracks (array of strings). Your function will update one property in one album of the collection.

Does this answer your question? I was a little unsure of what specific part you need help with.

1 Like

@ilenia @ArielLeslie Thanks for your help. You both have been big help. I have been sitting on this project for about 2weeks, trying to have my “ah ha” moment which is so satisfying. I know I will have my moment.

awesome, tell us if you need anymore help

ask all the questions you have! no stupid questions here

@ieahleen Ok. I’m sure I will need more help in the future. Thanks for your help.