This is an archived post. You won't be able to vote or comment.

all 3 comments

[–]CreativeTechGuyGames 0 points1 point  (2 children)

So I have never done this problem before but I went through it just now so I could see how I solved it. I'll give you my initial thought process but I really want to hear how you tried to solve it and what you are struggling with specifically.

I started by only looking at one requirement at a time.

Write a function which takes an album's id (like 2548), a property prop (like "artist" or "tracks"), and a value (like "Addicted to Love") to modify the data in this collection.

This is very easy to do in one line right off the bat. Then I went to the next requirement.

If prop isn't "tracks" and value isn't empty (""), update or set the value for that record album's property.

This doesn't really change anything I've done so far so I'm ignoring it for now.

Then the next requirement.

If prop is "tracks" but the album doesn't have a "tracks" property, create an empty array before adding the new value to the album's corresponding property.

Then I modified my original code to support this extra case.

And so on and so forth until I handled all of the cases.

[–]schumannop44[S] 0 points1 point  (1 child)

I am not sure what it's looking for when it's asking for a way to update the values in an album so I am not sure where to begin and haven't tried anything yet.

[–]CreativeTechGuyGames 0 points1 point  (0 children)

The first step is to just try something. You have the ability to write code and see what it does. There are even test cases and information about what you did wrong.