The current rules for the Record Collection challenge are:
- Your function must always return the entire record collection object.
- If
prop
isn’ttracks
andvalue
isn’t an empty string, update or set that album’sprop
tovalue
.- If
prop
istracks
but the album doesn’t have atracks
property, create an empty array and addvalue
to it.- If
prop
istracks
andvalue
isn’t an empty string, addvalue
to the end of the album’s existingtracks
array.- If
value
is an empty string, delete the givenprop
property from the album.
I was wondering if it would make sense to simplify the wording and the logic of users’ code by moving the last rule to be the 2nd and changing the existing 2nd rule to not talk about value
not being an empty string. These changes would not affect the tests but the algorithm would be simpler and the challenge be less wordy. Also, since we have taught users what assign
means and not set
, make we should replace set
with assign
here too.
My suggestion:
- Your function must always return the entire record collection object.
- If
value
is an empty string, delete the givenprop
property from the album.- If
prop
isn’ttracks
, update or assign that album’sprop
tovalue
.- If
prop
istracks
but the album doesn’t have atracks
property, create an empty array and addvalue
to it.- If
prop
istracks
andvalue
isn’t an empty string, addvalue
to the end of the album’s existingtracks
array.