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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started