Record Collection
It wasn’t a difficult activity because I was given the instruction on how to solve the problem which I was given and I am glad I was able to understand and be able to write theory and turn it into code.
Problem
You are given a JSON object representing a part of your musical album collection. Each album has several properties and a unique id number as its key. Not all albums have complete information. 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.
Approach
I checked if property of tracks is not equals to tracks and checked the value if is not equal to an empty string therefore I went inside the collection of records which I was given, and set them to that value. I checked again if prop is stricky equal to tracks and checked if collection doesn’t have its own property, I assigned an empty array and pushed the value to the collection as the last element. I had the third else if statement to push the value as the last element of an array. The last if statement deletes the value which is strickly equal to an empty string from the collection.
Conclusion
As I said above that it wasn’t a difficult activity and I was able to follow the instructions inoeder to complete the challenge.