Tell us what’s happening: Greetings, colleagues.
Day 3 of trying to solve this one and I am close to losing hope, haha!
Please, any guidance is welcomed and appreciated. I know I am close, but I just really don’t know what else to do.
On a somewhat unrelated note, is it ok to have two “then” (curly brackets) statements in one “if” statement? Also, how would one interpret “but” in JavaScript? I winged it with “&&”.
Thanks again.
**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 (prop != "tracks" && value != "")
{collection[id][prop] = value;}
if (prop == "tracks" && !collection[id][prop])
{collection[id][prop] = [];
collection[id][prop].push(value);}
if (prop == "tracks" && value != "")
{collection[id][prop].push(value);}
else if (value == "")
{delete collection[id][prop];}
return collection;
}
updateRecords(collection, 5439, 'artist', 'ABBA');
**Your browser information:**
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:87.0) Gecko/20100101 Firefox/87.0.
To be fair, I think we could come up with a better name for that variable. Really, I’d call it recordArray or something like that. It is not actually an object but rather an array of objects.