diff --git a/README.md b/README.md index ec852c4..575603a 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ npm install math-problems import { area, toCelsius, isEven, populationDensity, population } from 'math-problems'; // Calculate the area of a circle with radius 5 -console.log(area.circle(5)); // { area: 78 } +console.log(area.circle(5)); // 78 // Convert 100°F to Celsius console.log(toCelsius(100)); // 37 @@ -36,23 +36,23 @@ All area functions return an object with a floored `area` value. - **Rectangle** `rect(base: number, height: number)` - `area.rect(4, 5) ➔ { area: 20 }` + `area.rect(4, 5) ➔ 20` - **Triangle** `triangle(base: number, height: number)` - `area.triangle(4, 5) ➔ { area: 10 }` + `area.triangle(4, 5) ➔ 10` - **Rhombus** `rhombus(D: number, d: number)` - `area.rhombus(8, 6) ➔ { area: 24 }` + `area.rhombus(8, 6) ➔ 24` - **Trapezoid** `trapezoid(B: number, b: number, height: number)` - `area.trapezoid(10, 6, 5) ➔ { area: 40 }` + `area.trapezoid(10, 6, 5) ➔ 40` - **Circle** `circle(radius: number)` - `area.circle(3) ➔ { area: 28 }` + `area.circle(3) ➔ 28` ### 🌡️ Temperature Conversions Convert between Celsius (°C), Fahrenheit (°F), and Kelvin (K). @@ -124,4 +124,4 @@ Contributions are welcome! Please follow the [contribution guidelines](https://g ## License MIT © Igor Figueiredo -[Full License Text](LICENSE) \ No newline at end of file +[Full License Text](LICENSE) diff --git a/src/area.ts b/src/area.ts index 7fd6fde..a024dc0 100644 --- a/src/area.ts +++ b/src/area.ts @@ -10,10 +10,8 @@ export const area = { * * base * height */ - rect: (base: number, height: number): AreaResult => { - return { - area: Math.floor(base * height), - }; + rect: (base: number, height: number): number => { + return Math.floor(base * height); }, /** * @param base Size of the base of the triangle @@ -21,10 +19,8 @@ export const area = { * * (base * height) / 2 */ - triangle: (base: number, height: number): AreaResult => { - return { - area: Math.floor((base * height) / 2), - }; + triangle: (base: number, height: number): number => { + return Math.floor((base * height) / 2); }, /** * @param D larger diagonal @@ -32,10 +28,8 @@ export const area = { * * (D * d) / 2 */ - rhombus: (D: number, d: number): AreaResult => { - return { - area: Math.floor((D * d) / 2), - }; + rhombus: (D: number, d: number): number => { + return Math.floor((D * d) / 2); }, /** * @param B Larger base @@ -44,24 +38,15 @@ export const area = { * * ((B + b) * height) / 2 */ - trapezoid: (B: number, b: number, height: number): AreaResult => { - return { - area: Math.floor(((B + b) * height) / 2), - }; + trapezoid: (B: number, b: number, height: number): number => { + return Math.floor(((B + b) * height) / 2); }, /** * @param radius Circle radius * * π * (radius * radius) */ - circle: (radius: number): AreaResult => { - return { - area: Math.floor(PI * (radius * radius)), - }; + circle: (radius: number): number => { + return Math.floor(PI * (radius * radius)); }, }; - -export type AreaResult = { - area?: number; - perimeter?: number; -};