Tell us what’s happening:
i got a right answer for all my tasks . but i did not pass them . can somebody tell me where is my problem.
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==="") delete records[id][prop];
if (prop!=="tracks" && value!=="")records[id][prop]=value;
if(prop==="tracks" && value!=="" && records[id].hasOwnProperty("tracks")==false)records[id].tracks =value;
if(prop ==="tracks" && value!=="")records[id][prop].push(value);
return records;
}
//test 2
console.log(updateRecords(recordCollection, 5439, "artist", "ABBA"));
//test3
console.log(updateRecords(recordCollection, 5439, "tracks", "Take a Chance on Me"))
//4
console.log(updateRecords(recordCollection, 2548, "artist", ""))
//test5
console.log(updateRecords(recordCollection, 1245, "tracks", "Addicted to Love"))
//test6
console.log(updateRecords(recordCollection, 2468, "tracks", "Free"))
//test7
console.log(updateRecords(recordCollection, 2548, "tracks", ""))
//test8
console.log(updateRecords(recordCollection, 1245, "albumTitle", "Riptide"))
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:152.0) Gecko/20100101 Firefox/152.0
Challenge Information:
Build a Record Collection - Build a Record Collection