Tell us what’s happening:
Describe your issue in detail here.
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) {
function updateRecords(records, id, prop, value) {
if (value === "") {
delete records[prop];
}else if(prop !=="tracks" && value!==" "){
records[prop]=value;
} else if (prop === "tracks"&& value!==" ") {
records[tracks].push(value);
} else {
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/112.0.0.0 Safari/537.36
Challenge: Basic JavaScript - Record Collection
Link to the challenge:
Please Tell us what’s happening in your own words.
Learning to describe problems is hard, but it is an important part of learning how to code.
Also, the more you say, the more we can help!
The last sentence on the code is troughing an error
“updateRecords(recordCollection, 5439, “artist”, “ABBA”);”
I don’t think this does what you want. Where is id
?
Same problem here
I dint get you . Why would i need to use id ?
it doesn’t specify in the question
Those bullet points talk about ‘the album’. How do you get the specific album you are supposed to update?
Please stop posting pictures at me. I’m not sure how that picture answers my question.
The records
is a lot of albums. You are supposed to only update one album. The id
tells you which album, so you need it in your code somewhere so you are updating the right album.
Tell us what’s happening:
Describe your issue in detail here.
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 (value === "") {
delete records[id][prop];
}else if(prop !=="tracks" && value!==" "){
records[id][prop]=value;
} else if (prop === "tracks"&& value!==" ") {
records[tracks].push(value);
} else {
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/112.0.0.0 Safari/537.36
Challenge: Basic JavaScript - Record Collection
Link to the challenge:
Learn to Code — For Free
Can you describe what issue you are having with this challenge please? The more you say, the more we can help!
You shouldn’t care if the value is a string with a single space
You are not checking for or handling the case where the tracks array doesn’t exist yet.
It really makes it easier to help if you use your own words to tell us what help you need