Question: Write functions to transform results into a new Object format. * * The `transformObservation(original)` function takes an observation Object that * looks like the results

Write functions to transform results into a new Object format. 

*

* The `transformObservation(original)` function takes an observation Object that

* looks like the results values in src/data.js, and transforms the data into a new

* Object that looks like this (see comments on right-hand side with details):

*

* {

* id: 67868131, // copy the id over without modification

* speciesGuess: 'Muskrat', // species_guess renamed

* isResearchQuality: true, // true if quality_grade is 'research', false otherwise

* geoCoords: [-79.3565522733, 43.798774894], // location converted to Array of Numbers, longitude first

* photoUrls: [ // modify photos to be Array of URLs

* 'https://static.inaturalist.org/photos/109762131/square.jpg?1610308133'

* ],

* photosCount: 1, // the number of photo URLs included in photos

* user: '@dridgen' // the user's login_exact name with @ prefix added

* }

******************************************************************************/

function transformObservation(original) {}

/*******************************************************************************

* Problem 3 Part II: transformObservations(data) with iteration

*

* The `transformObservations(data)` function takes observation data and uses it

* to create and return a new Array of transformed observation Objects,

* calling the transformObservation() function you wrote above on each one.

*

* In your solution, make use of the following:

*

* - a new empty Array to hold all the transformed cases

* - a for-loop or .forEach() method to loop over all Objects in the data results Array

* - pass each observation Object to your transformObservation() function to get a new Object

* - add the new, transformed Object to your array

* - return the new Array containing all the transformed Objects

******************************************************************************/

function transformObservations(data) {}

/*******************************************************************************

* Problem 3 Part III: transformObservations2(data) with .map()

*

* Rewrite your transformObservations() function from above a second time using

* the Array .map() method see:

* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map

*

* In your solution, make use of the following:

*

* - use the .map() method of the data results Array to create a new Array

* - In the .map() method's function, call your transformObservation() function

* - return the Array created by the .map() method

******************************************************************************/

function transformObservations2(data) {}

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!