Skip to content

Commit

Permalink
feat: add multiply function
Browse files Browse the repository at this point in the history
  • Loading branch information
marsidev committed Aug 15, 2024
1 parent 898fb46 commit c2e0dc0
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from "./types.js";
export * from "./greet.js";
export * from "./sum.js";
export * from "./types.js";
export * from "./multiply.js";
20 changes: 20 additions & 0 deletions src/multiply.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { describe, expect, it } from "vitest";
import { multiply } from "./multiply.js";

describe("multiply", () => {
it("multiplies two numbers", () => {
expect(multiply(2, 3)).toBe(6);
});

it("multiplies two negative numbers", () => {
expect(multiply(-2, -3)).toBe(6);
});

it("multiplies a positive and a negative number", () => {
expect(multiply(2, -3)).toBe(-6);
});

it("multiplies two floating point numbers", () => {
expect(multiply(1.1, 2.2)).toBeCloseTo(2.42);
});
});
3 changes: 3 additions & 0 deletions src/multiply.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export function multiply(a: number, b: number): number {
return a * b;
}

0 comments on commit c2e0dc0

Please sign in to comment.