From a19d436026fbfc35a8ef584b5f3d8f8abc9262ce Mon Sep 17 00:00:00 2001 From: nitcord <72227790+nitcord@users.noreply.github.com> Date: Thu, 13 Feb 2025 23:10:00 +0000 Subject: [PATCH 1/3] Update area.ts --- src/area.ts | 35 ++++++++++------------------------- 1 file changed, 10 insertions(+), 25 deletions(-) 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; -}; From df4dfc04a8a352fc0c0826171578cc4fb3bec2dd Mon Sep 17 00:00:00 2001 From: nitcord <72227790+nitcord@users.noreply.github.com> Date: Thu, 13 Feb 2025 23:24:04 +0000 Subject: [PATCH 2/3] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index ec852c4..58eb213 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 @@ -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) From 451fbaea308c9b3cb9219cb493c21e101566c4ae Mon Sep 17 00:00:00 2001 From: Igor <80823011+igorwastaken@users.noreply.github.com> Date: Thu, 13 Feb 2025 20:26:05 -0300 Subject: [PATCH 3/3] Update README.md --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 58eb213..575603a 100644 --- a/README.md +++ b/README.md @@ -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).