Hello - thanks for that camp, i’m not new in the IT but noob in JS,
so I’ve try that lesson - one day is gone … and now I’ve a question.
I start with help from video, try my self ‘solution’ and same form forum - no luck.
ok back too roots and try only one by one condition and check exactly that it do …
Can it be that delete recordCollection[id][prop]; deletes more in that env as it should.
Check it in codepen.io who it do rigth.
great, you can see my ‘work’, so here also console output - as I see, propertie artist is also gone?
Thank you for Help.
// — console --_
Start Func: [object Object] 2548 tracks
no value so DO delete: 2548 tracks - next line(s) array befor and after delete
so artist is also ‘gone’??
{ albumTitle: ‘Slippery When Wet’,
artist: ‘Bon Jovi’,
tracks: [ ‘Let It Rock’, ‘You Give Love a Bad Name’ ] }
{ albumTitle: ‘Slippery When Wet’, artist: ‘Bon Jovi’ }
// — EOF —
**Your code so far**
// 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) {
console.log("Start Func: "+records+" " +id+" "+ prop +" "+ value);
if(!value){
console.log("no value so DO delete: " + id + " " + prop + " - next line(s) array befor and after delete
so artist is also 'gone'??");
console.log(recordCollection[id]);
delete recordCollection[id][prop];
console.log(recordCollection[id]);
}
}
//updateRecords(recordCollection, 5439, 'artist', 'ABBA');
//updateRecords(recordCollection, 5439, "tracks", "Take a Chance on Me");
//console.log('id 5439 tracks: ' + recordCollection[5439].tracks)
///*updateRecords(recordCollection, 2548, "artist", "");
//updateRecords(recordCollection, 1245, "tracks", "Addicted to Love");
//updateRecords(recordCollection, 2468, "tracks", "Free");
updateRecords(recordCollection, 2548, "tracks", "");
//updateRecords(recordCollection, 1245, "albumTitle", "Riptide")
//*/
//console.log(recordCollection);
**Your browser information:**
User Agent is: Mozilla/5.0 (X11; Linux x86_64; rv:101.0) Gecko/20100101 Firefox/101.0
Challenge: Basic JavaScript - Record Collection
Link to the challenge: