Question
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; } */
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
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