Tell us what’s happening:
Describe your issue in detail here.
Please do not mind my code. I know that he is not working well because i still lack some basic skills about it.
I was wondering one thing about this problem.
How do I “recognize” the different input that are stated in the function updateRecords ?
I can’t find how and what “records” purpose have. Which information is he gathering on this specific matter ? What is his anchor point ?
Also value, how can i know which part of the function is he working on ?
It’s a complete nightmare but i am starting to see the light, still, if someone can help me, i am pretty sure other people are still wondering on how this is all working.
Also, if i could add something, on the second task to accomplish, we have to target the ‘tracks’ value, but have to go through records[id].hasOwnProperty(“tracks”), how do i know that it’s the right path ?
Thanks in advance,
**Your code so far**
// Setup
const 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) {
if (prop !== 'tracks' && value !== "") {
return prop = value;
} else if (prop == "tracks" && "tracks" != undefined) {
var array = [];
var add = array.push(value);
} else if (prop == 'tracks' && value != "") {
array.push(value);
} else if (value == "") {
delete recordCollection.prop;
}
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/104.0.0.0 Safari/537.36
Challenge: Basic JavaScript - Record Collection
Link to the challenge: