Tell us what’s happening:
Hello!
I have tried multiple variations of my code, as well as checked for answers on the forum and I just can’t understand why my code isn’t working. It only passes the first check to have an updateRecords function.
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'
}
};
const records = recordCollection;
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 !== "") {
if (records.id.tracks === "") {
records.id.tracks = [];
records.id.tracks.push(value)
} else {
records.id.tracks.push(value)
}
}
return records;
}
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:147.0) Gecko/20100101 Firefox/147.0
Challenge Information:
Build a Record Collection - Build a Record Collection
