Tell us what’s happening:
I’ve been stuck on this exercise for a couple weeks. I’ve used MDN and Google to try and solve all of the stories. I’m getting there, but I need help on a couple of tests.
Your code so far
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'
}
};
function updateRecords(records, id, prop, value) {
if (value === "") {
// rule #2, delete property if value is empty
delete records[id][prop];
} else if (prop !== "tracks" && value !== "") {
// rule #3, assign value
records[id][prop] = records[id][prop].value;
} else {
records[id][prop] = records[id][prop] || []; // rule #4, create an array if missing
records[id][prop].push([value]); // rule #5, add value to array
}
return records; //rule #1, always return records object
}
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/142.0.0.0 Safari/537.36
Challenge Information:
Build a Record Collection - Build a Record Collection