Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

You are given a list of temperatures that occurred for major US cities over the past week. Temperature readings were taken at inconsistent intervals. Process

You are given a list of temperatures that occurred for major US cities over the past week. Temperature readings were taken at inconsistent intervals. Process the temperature readings and create a function that will return a summary of the temperature data for a given day. The summary should include the following information: - First temperature reading for the day - Last temperature reading for the day - Highest temperature reading for the day - Lowest temperature reading for the day - Average of temperature readings that day

Descriptions of the two functions are below.

Function Descriptions: Write functions processReadings and getTemperatureSummary in the editor below. The processReadings function will be called once with a list of temperature readings and returns nothing.

The getTemperatureSummary function will be called any number of times with a date and city, and returns the temperature summary for that day in that city. If there is no temperature data for that day and city, return null.

Function Declarations: Examples of the function declarations in typescript are below.

function getTemperatureSummary(date: Date, city: string): TemperatureSummary { // TODO: implement }

function processReadings(readings: TemperatureReading[]): void { // TODO: implement }

/* For your reference interface TemperatureReading { time: Date; temperature: number; city: string; }

Interface TemperatureSummary{ first: number; last: number; high: number; low: number; average: number; } */

image text in transcribed

Programming Language: JavaScript

You are given a list of temperatures that occurred for major US cities over the past week. Temperature readings were taken at inconsistent intervals. Process the temperature readings and create a function that will return a summary of the temperature data for a given day. The summary should include the following information: - First temperature reading for the day Last temperature reading for the day Highest temperature reading for the day Lowest temperature reading for the day - Average of temperature readings that day Descriptions of the two functions are below. Function Descriptions: Write functions "processReadings" and "getTemperatureSummary" in the editor below. The "processReadings" function will be called once with a list of temperature readings and returns nothing. The "getTemperatureSummary" function will be called any number of times with a date and city, and returns the temperature summary for that day in that city. If there is no temperature data for that day and city, return null. Function Declarations: Examples of the function declarations in typescript are below. function getTemperatureSummary (date: Date, city: string): TemperatureSummary { // TODO: implement function processReadings (readings: TemperatureReading[]): void { // TODO: implement } /* For your reference interface TemperatureReading { time: Date; temperature: number; city: string; } Interface Temperature Summary{ first: number; last: number; high: number; low: number; average: number; } */

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

Automating Access Databases With Macros

Authors: Fish Davis

1st Edition

1797816349, 978-1797816340

More Books

Students also viewed these Databases questions