Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Income Tax Fundamentals 2013

Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill

31st Edition

1111972516, 978-1285586618, 1285586611, 978-1285613109, 978-1111972516

More Books

Students also viewed these Programming questions

Question

What is the primary goal of unit testing?

Answered: 1 week ago

Question

Recognize the causes and symptoms of stress.

Answered: 1 week ago