From 67a4420c7bd3970cc6974998b71a75b5c7dc823f Mon Sep 17 00:00:00 2001 From: Valery Malyshev Date: Sat, 15 Jun 2024 03:57:26 +0300 Subject: [PATCH] Even or Odd --- 8_kyu/Even or Odd/README.md | 5 +++++ 8_kyu/Even or Odd/index.test.ts | 19 +++++++++++++++++++ 8_kyu/Even or Odd/index.ts | 3 +++ README.md | 4 ++-- kata.md | 1 - 5 files changed, 29 insertions(+), 3 deletions(-) create mode 100644 8_kyu/Even or Odd/README.md create mode 100644 8_kyu/Even or Odd/index.test.ts create mode 100644 8_kyu/Even or Odd/index.ts diff --git a/8_kyu/Even or Odd/README.md b/8_kyu/Even or Odd/README.md new file mode 100644 index 0000000..cd31dca --- /dev/null +++ b/8_kyu/Even or Odd/README.md @@ -0,0 +1,5 @@ +## Even or Odd + +https://www.codewars.com/kata/53da3dbb4a5168369a0000fe + +Create a function that takes an integer as an argument and returns "Even" for even numbers or "Odd" for odd numbers. diff --git a/8_kyu/Even or Odd/index.test.ts b/8_kyu/Even or Odd/index.test.ts new file mode 100644 index 0000000..48f637f --- /dev/null +++ b/8_kyu/Even or Odd/index.test.ts @@ -0,0 +1,19 @@ +import { evenOrOdd } from "./index"; + +describe("Tests", () => { + it("evenOrOdd(1) should return 'Odd'", function () { + expect(evenOrOdd(1)).toBe("Odd"); + }); + it("evenOrOdd(2) should return 'Even'", function () { + expect(evenOrOdd(2)).toBe("Even"); + }); + it("evenOrOdd(-1) should return 'Odd'", function () { + expect(evenOrOdd(-1)).toBe("Odd"); + }); + it("evenOrOdd(-2) should return 'Even'", function () { + expect(evenOrOdd(-2)).toBe("Even"); + }); + it("evenOrOdd(0) should return 'Even'", function () { + expect(evenOrOdd(0)).toBe("Even"); + }); +}); diff --git a/8_kyu/Even or Odd/index.ts b/8_kyu/Even or Odd/index.ts new file mode 100644 index 0000000..294d9bd --- /dev/null +++ b/8_kyu/Even or Odd/index.ts @@ -0,0 +1,3 @@ +export function evenOrOdd(number: number): string { + return number % 2 === 0 ? "Even" : "Odd"; +} diff --git a/README.md b/README.md index 1c08339..e277464 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,8 @@ ### Katas solved -`Total`: 102 \ -`8_kyu`: 85 \ +`Total`: 103 \ +`8_kyu`: 86 \ `7_kyu`: 13 \ `6_kyu`: 4 \ `5_kyu`: 0 \ diff --git a/kata.md b/kata.md index 276dc95..7c43013 100644 --- a/kata.md +++ b/kata.md @@ -1,2 +1 @@ -8 kyu - Even or Odd - https://www.codewars.com/kata/53da3dbb4a5168369a0000fe 8 kyu - Beginner - Reduce but Grow - https://www.codewars.com/kata/57f780909f7e8e3183000078