Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

So that you can easily access the CO2 dataset, Ive set up a web page at https://ics-software-engineering.github.io/uhdata/co2.js that defines a variable called co2 whose value

So that you can easily access the CO2 dataset, Ive set up a web page at https://ics-software-engineering.github.io/uhdata/co2.js that defines a variable called co2 whose value is an array of objects, one for each row in the table. Heres what the first couple of rows look like:

const co2 = [ { "year": 1959, "mean": 315.98, "unc": 0.12 }, { "year": 1960, "mean": 316.91, "unc": 0.12 },

For this WOD, you should first implement a function called safe(data, year). This function should take a parameter providing a dataset structured like co2, and a year (such as 2020), and return true if that year is less than 351 ppm on average.

Second, please implement a function called numSafe(data). This function should take a parameter providing a dataset structured like co2, and return the total number of years in which CO2 levels were less than 351 ppm.

To test your code, you can try this:

console.log(safe(co2, 1960)); // prints true console.log(safe(co2, 2020)); // prints false console.log(numSafe(co2)); // prints 29

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

More Books

Students also viewed these Databases questions