Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 14 additions & 9 deletions src/temperatures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

/**
Expand All @@ -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
}

/**
Expand All @@ -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
}

/**
Expand All @@ -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
}

/**
Expand All @@ -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
}

/**
Expand All @@ -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 {
Expand Down