I was on the Record Collection Challenge of the JS section of the curriculum and I noticed something.
there is a test to be passed which is: After
updateRecords(2548, "tracks", "") , tracks should not be set
the record collection with the id of 2548 already has tracks. The issue is that the solution given or the problem itself, does not explain that to update you must delete the tracks already on the record… My point is, since record 2548 has tracks 2 tracks, if when we run updateRecords(2548, “tracks”, “”), “tracks” should not be set, then why are we SETTING IT as empty when the update should just leave the tracks.
This boils down to the fact that when you check for “value”, if there is not any we delete the entire prop. I do not agree with the presentation of this problem. There should be a note explaining that when value is empty IT DOES NOT MATTER IF THE RECORD ALREADY HAD VALUES ON SUCH PROP IF THE FUNCTION IS CALLED WITH NO VALUE TO IT, THEN REGARDLESS OF THE CONTENTS OF THE PROP, IT SHOULD BE DELETED.
This would be fine, but then the problem would be that it does not concord with real scenarios.
It is an odd thing to see a music library with a registered bon jovi (artist), an album (Slippery When wet) and not see songs in the album.
a song belongs to an album, so if there arent any songs, there shouldnt be an album nor an artist (if there aren’t any registered albums)
Bottomline, i think the problem should be rephrased.
The contradiction can become quite the headache. It needs to relate more to real life.
I apologize if my comment is ignorant, i just saw it that way. Please advice me about my view on this. Thank you for everything you do! All the best