Record Collection need an approach

Hi omkarkothavale88,

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.

If prop is “tracks” and value isn’t empty (“”), push the value onto the end of the album’s existing tracks array.

If value is empty (“”), delete the given prop property from the album.

Let’s disect the guide.

  1. If prop is “tracks” and value isn’t empty (“”)

(First) conditional prop === “tracks” AND value != “”

  1. push the value onto the end of the album’s existing tracks array

If TRUE, create second conditional, does the property exist? If TRUE, push to array.

If FALSE (on the second conditional), meaning props === “tracks” the no existing value. put value (not push).

  1. 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.

meaning the result is FALSE, (it doesn’t have “tracks” property), create the property then add the value.

  1. If value is empty (“”), delete the given prop property from the album.

Create conditional, if value != “” AND property exist, delete the property.

More help on this: Hint and Spoilers

3 Likes