Tell us what’s happening:
I’m confused. Everything runs as its supposed to when I check the console - all the answers are correct, yet it keeps telling me something is wrong.
I follow the tutorial given by Beau on YouTube at the same time as I go through this online course - it helps me to learn and I take notes for future reference. Usually I complete the exercises on my own.
But in this exercise I used his code . Maybe I’m missing something and I just can’t see it from looking at it for so long?!
Would love some feedback please as I’d like to understand but also progress through the course!
Thank you
Your code so far
// Setup
var collection = {
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(object, id, prop, value) {
if (value === "") {
delete collection[id][prop];
} else if (prop === "tracks") {
collection[id][prop] = collection[id][prop] || [];
collection[id][prop].push(value);
} else {
collection[id][prop] = value;
}
return object;
}
console.log(updateRecords(collection,5439,"artist","ABBA"));
console.log(updateRecords(collection,5439,"tracks","Take a Chance on Me"));
console.log(updateRecords(collection,2548,"artist",""));
console.log(updateRecords(collection,1245,"tracks","Addicted To Love"));
console.log(updateRecords(collection,2468,"tracks","Free"));
console.log(updateRecords(collection,2548,"tracks",""));
console.log(updateRecords(collection,1245,"albumTitle","Riptide"))
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 11_1_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36
.
Challenge: Record Collection
Link to the challenge: