Good day,
So I’ve been doing basic javascript lessons and ran into a roadblock. Im using the ? operator instead of “if else” for the solution, and it worked when I tested it.
In console, the output for console.log(recordCollection[5439]) is
{ albumTitle: ‘ABBA Gold’, artist: ‘ABBA’ }
But it won’t accept my answer. It says artist should be string ‘ABBA’. Can someone help?
Here’s my code
// 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) {
return value == "" ?
delete records[id][prop]
: prop !== 'tracks' && value !== "" ?
records[id][prop] = value
: prop == 'tracks' && value !== "" ?
records[id].hasOwnProperty("tracks") == false ?
records[id][prop] = [value]
: records[id][prop].push(value)
: "Error";
}
updateRecords(recordCollection, 5439, 'artist', 'ABBA');
console.log(recordCollection[5439])
Thank you