Tell us what’s happening:
Please be patient with me I am so new to this and I am really trying my best before posting a question. I have read other people’s explanations and they didn’t help specifically with my confusion. There is also no video for this one.
I am so confused by this question. I have spent hours re-reading it and trying to break it down. I feel extremely discouraged.
I almost feel like after just learning some of the js basics, I need more clarity in the question to help me identify what steps I need to do.
I cannot find a specific goal or question layed out in the problem. Forgive me if I sound a bit frustrated, I am just upset that I feel I am trying to break it down and it isn’t making
sense based on the wording.
I have broken it down and examined the reasons for my confusion and I am going to present all of my questions below:
- “If prop isn’t tracks and value isn’t an empty string, update or set that album’s prop to value.”
how can we identify the property using ‘prop’ in an if statement if prop is not defined to know it represents a property?
Same question goes for “value.” If I try to think on how to define it I feel like I am wrong but I was thinking of using recordCollection.getOwnPropertyNames() somehow, but then I would have
to include all of the objects and then an if statement based on the object’s contents.
recordCollection.getOwnPropertyNames(2548, 2468, 1245, 5439) ← no one taught about making a comma separated list like this so I believe me to be completely off base.
-
I am interpreting value as the actual items in the key, ex: [‘Let It Rock’, ‘You Give Love a Bad Name’] and ‘Robert Palmer’, etc. So if these are the values, how does request make sense?
“If prop isn’t tracks and value isn’t an empty string, update or set that album’s prop to value.”
We are setting a property to the value? I don’t understand why we would do that and therefore I feel like I am understanding wrong.
This specific confusion also makes it hard to even start my function. -
“If prop is tracks but the album doesn’t have a tracks property, create an empty array and add value to it.” Again the ‘value’ is tripping me up, because how can I “add value” to it?
Does it just want me to input something random? If so, why does it say create an empty array?? -
“If prop is tracks and value isn’t an empty string, add value to the end of the album’s existing tracks array.” Same type of confusion around value.
-
“If value is an empty string, delete the given prop property from the album.” --This I think I understand to just represent tracks in this object. I am struggling to think of how to describe
it as empty, but I think I am just not using my head as much because I have exhausted my brain cells on the previous issues.
1245: {
artist: ‘Robert Palmer’,
tracks:
},Your code so far
// Setup
var recordCollection = {
2548: {
albumTitle: 'Slippery When Wet',
artist: 'Bon Jovi',
tracks: ['Let It Rock', 'You Give Love a Bad Name']
},
2468: {
albumTitle: '1999',
artist: 'Prince',
tracks: ['1999', 'Little Red Corvette']
},
1245: {
artist: 'Robert Palmer',
tracks: []
},
5439: {
albumTitle: 'ABBA Gold'
}
};
// Only change code below this line
function updateRecords(records, id, prop, value) {
return records;
}
updateRecords(recordCollection, 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/91.0.4472.164 Safari/537.36
Challenge: Record Collection
Link to the challenge: