Tell us what’s happening:
hello everyone, test 2,5,6 and 8 fail to pass although the log are corrects. I need your’s help to completed this lab
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 updateRecords = (records, id, prop, value) => {
if(value === ""){
console.log(delete records[id][prop]);
} if ((prop !== "tracks")&& (value !== "")){
console.log(records[id][prop] = value);
//If prop is tracks and value isn't an empty string, add value to the end of the album's existing tracks array.
}if (((prop === "tracks")&& (value !== "")) &&(records[id].hasOwnProperty("tracks") === true)){
records[id][prop].push(value);
console.log(records[id][prop])
//If prop is tracks and value isn't an empty string, but the album doesn't have a tracks property, create an empty array and add value to it.
} else if (((prop === "tracks")&& (value !== "")) &&(records[id].hasOwnProperty("tracks") !== true)){
records[id][prop]=[value]
console.log(records[id][prop] );
}
}
updateRecords(recordCollection, 1245, "tracks", "Addicted to Love")
Your browser information:
User Agent is: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/142.0.0.0 Safari/537.36
Challenge Information:
Build a Record Collection - Build a Record Collection