I dont understand the exercise

Tell us what’s happening:
I dont understand what i have to do. I have watched the video but still dont get it. For me it gets very complicated from here. I am currently working on the javascript curriculum on fCC.

Your code so far
Look below.


// 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.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) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.88 Safari/537.36.

Challenge: Record Collection

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

now it’s not only coding
now it becomes problem solving
it is a skill as any one else, acquired through practice and frustration

try breaking down the instructions in the challenge in smaller steps, try doing a paragraph at a time
first you need to be able to explain how to get the desired output from that input , and what output

2 Likes

this could be a good start, what part are you trying to satisfy with this?
do you remember how to work with objects?

1 Like

Thanks madam, for your fast reply!! :smiley:

That line means: if prop is not “tracks” and value is not empty, then acces prop in the collection variable. Am I right?

not really
first, dot notation access a property name literally, so you are looking for a property named “prop” on the collection object - I suggest you review that part of syntax, how to access object properties
second, what kind of properties does the object have? look at it carefully

btw interesting blog you have! I clicked on it and i liked what I saw! Will follow up with you on that

First of all you have my sympathies! This challenge really stopped me in my tracks. My approach was to have a peek at the hint. Go back to challenge, get stuck, take another peek, go back the challenge, get stuck, etc. In the end I really understood the code and how it worked. The lightbulb went on once my code was mostly working and I could change the parameters in the function and see how the arrays changed. When I could see exactly how the function changed the array.

So my point is that in this case it might be ok to get some hints to make it mostly work and then play around with the function to see how it works. You can then erase everything and start from scratch. Believe me it will still be a challenge!

One final note about the code in the video. He uses the Logical OR operator ( || ) and it works perfectly. Cleaner than what I did. However, as he admits, it’s a “fancy” way to do it and one that the curriculum didn’t cover at all as much as IF and ELSE statements so that might have thrown you. It’s a better solution but maybe just one step advanced at this point IMHO.

1 Like

I am trying it now with the hints. I try not to copy paste because then I will learn nothing. I try to study the code and the explenation.

This gives me headaches shittt! But I keep trying!