Question: Must in JAVASCRIPT Problem 02: observationsByPrivacy(data, privacy) * * iNaturalist users can hide or alter the geolocation coordinate data for an * observation they make.

Must in JAVASCRIPT

Problem 02: observationsByPrivacy(data, privacy)

*

* iNaturalist users can hide or alter the geolocation coordinate data for an

* observation they make. For example, I might see a butterfly in my backyard,

* but don't want to share the location of my home.

*

* Write a function that takes Observation data, as well as a `privacy` value.

* The `privacy` value describes whether the geolocation data is "open",

* "obscured", or null (i.e., unspecified).

*

* If the privacy value isn't one of "open", "obscured", or null

* throw an error. Make sure you deal with UPPER- and lower-case versions of the

* strings when checking.

*

* Return a new Array with only those observation Objects that contain a privacy

* value that matches the privacy argument to your function. For example:

*

* observationsByPrivacy(data, "open") would return an Array of observation

* objects that have `privacy: "open"`.

*

* observationsByPrivacy(data, null) would return an Array of observation

* objects that have `privacy: null`.

*

* observationsByPrivacy(data, "OPEN") would return an Array of observation

* objects that have `privacy: "open"` (i.e., UPPERCASE privacy values

* should be converted to lowercase).

*

* In your solution, make use of the following:

*

* - make sure that privacy is of the right type and value, or throw an Error

* - create an empty array

* - use a for...of loop to loop over all Objects in results

* - if an observation includes the given privacy value, add the observation

* Object to the empty Array. Make sure you deal with both UPPER and lowercase

* privacy values: all privacy values on the observations are lowercase.

*

* Your function should return the newly created Array.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!