diff --git a/src/temperatures.ts b/src/temperatures.ts index bc788d5..7a1e9db 100644 --- a/src/temperatures.ts +++ b/src/temperatures.ts @@ -16,8 +16,8 @@ const temperatures = [ */ function filterHighTemperatures(temps: number[]): number[] { // Your code here - - return []; // replace the empty array with what you see is fit + const highTemperatures = temps.filter((temp) => temp >= 25); + return highTemperatures; } /** @@ -29,8 +29,8 @@ function filterHighTemperatures(temps: number[]): number[] { */ function filterLowTemperatures(temps: number[]): number[] { // Your code here - - return []; // replace the empty array with what you see is fit + const lowTemperatures = temps.filter((temp) => temp < 20); + return lowTemperatures; } /** @@ -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 + const fahrenheitTemperatures = temps.map((temp) => (temp * 9) / 5 + 32); + return fahrenheitTemperatures; } /** @@ -61,8 +61,12 @@ type TemperatureLabel = "Warm" | "Mild" | "Cool"; function labelTemperatures(temps: number[]): TemperatureLabel[] { // Your code here - - return []; // replace the empty array with what you see is fit + const temperatureLabels = temps.map((temp) => { + if (temp >= 25) return "Warm"; + else if (temp >= 20 && temp <= 24) return "Mild"; + return "Cool"; + }); + return temperatureLabels; } /** @@ -74,8 +78,8 @@ function labelTemperatures(temps: number[]): TemperatureLabel[] { */ function getMaxTemperature(temps: number[]): number { // Your code here - - return -1; // replace -1 with what you see is fit + const maxTemperature = Math.max(...temps); + return maxTemperature; } /** @@ -87,8 +91,8 @@ function getMaxTemperature(temps: number[]): number { */ function getMinTemperature(temps: number[]): number { // Your code here - - return -1; // replace -1 with what you see is fit + const minTemperature = Math.min(...temps); + return minTemperature; } export {