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
22 changes: 10 additions & 12 deletions src/temperatures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,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((number)=> number >= 25);
}

/**
Expand All @@ -29,8 +28,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((number)=> number < 20);
}

/**
Expand All @@ -43,8 +41,7 @@ function filterLowTemperatures(temps: number[]): number[] {
*/
function convertCelsiusToFahrenheit(temps: number[]): number[] {
// Your code here

return []; // replace the empty array with what you see is fit
return temps.map((number)=> (number * 9/5) +32);
}

/**
Expand All @@ -61,8 +58,11 @@ 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(temp =>{
if(temp < 20) return "Cool"
if(temp >= 25) return "Warm"
return "Mild"
})
}

/**
Expand All @@ -74,8 +74,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 temps.reduce((max, current)=> current > max ? current : max)
}

/**
Expand All @@ -87,8 +86,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 temps.reduce((min, current)=> current < min ? current : min)
}

export {
Expand Down