diff --git a/src/temperatures.ts b/src/temperatures.ts index bc788d5..7f10164 100644 --- a/src/temperatures.ts +++ b/src/temperatures.ts @@ -17,7 +17,7 @@ const temperatures = [ function filterHighTemperatures(temps: number[]): number[] { // Your code here - return []; // replace the empty array with what you see is fit + return temps.filter((temp) => temp >= 25); // replace the empty array with what you see is fit } /** @@ -30,7 +30,7 @@ function filterHighTemperatures(temps: number[]): number[] { function filterLowTemperatures(temps: number[]): number[] { // Your code here - return []; // replace the empty array with what you see is fit + return temps.filter((temp) => temp < 20); // replace the empty array with what you see is fit } /** @@ -43,8 +43,8 @@ function filterLowTemperatures(temps: number[]): number[] { */ function convertCelsiusToFahrenheit(temps: number[]): number[] { // Your code here - - return []; // replace the empty array with what you see is fit + let temperatures1: number[] = temps.map((num) => (num * 9/5) + 32); + return temperatures1;; // replace the empty array with what you see is fit } /** @@ -61,8 +61,14 @@ type TemperatureLabel = "Warm" | "Mild" | "Cool"; function labelTemperatures(temps: number[]): TemperatureLabel[] { // Your code here - - return []; // replace the empty array with what you see is fit + return temps.map((t) => { + if (t >= 25) + return "Warm"; + else if (t >= 20) + return "Mild"; + else + return "Cool"; + });; // replace the empty array with what you see is fit } /** @@ -74,8 +80,7 @@ function labelTemperatures(temps: number[]): TemperatureLabel[] { */ function getMaxTemperature(temps: number[]): number { // Your code here - - return -1; // replace -1 with what you see is fit + return Math.max(...temps); // replace -1 with what you see is fit } /** @@ -88,7 +93,7 @@ function getMaxTemperature(temps: number[]): number { function getMinTemperature(temps: number[]): number { // Your code here - return -1; // replace -1 with what you see is fit + return Math.min(...temps); // replace -1 with what you see is fit } export {