Skip to content

Commit

Permalink
You only need one - Beginner
Browse files Browse the repository at this point in the history
  • Loading branch information
PheRum committed Jun 14, 2024
1 parent 5143c26 commit 27c45a3
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 4 deletions.
2 changes: 1 addition & 1 deletion 8_kyu/No Loops 2 - You only need one/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export function check(a: (string | number)[], x: string | number): boolean {
export function check<T>(a: T[], x: T): boolean {
return a.includes(x);
}
9 changes: 9 additions & 0 deletions 8_kyu/You only need one - Beginner/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
## You only need one - Beginner

https://www.codewars.com/kata/57cc975ed542d3148f00015b

You will be given an array a and a value x. All you need to do is check whether the provided array contains the value.

Array can contain numbers or strings. X can be either.

Return true if the array contains the value, false if not.
10 changes: 10 additions & 0 deletions 8_kyu/You only need one - Beginner/index.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { check } from "./index";

describe("Tests", () => {
it("example", () => {
expect(check([66, 101], 66)).toBe(true);
expect(check([80, 117, 115, 104, 45, 85, 112, 115], 45)).toBe(true);
expect(check(["t", "e", "s", "t"], "e")).toBe(true);
expect(check(["what", "a", "great", "kata"], "kat")).toBe(false);
});
});
3 changes: 3 additions & 0 deletions 8_kyu/You only need one - Beginner/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export function check<T>(a: T[], x: T): boolean {
return a.includes(x);
}
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

### Katas solved

`Total`: 78 \
`8_kyu`: 61 \
`Total`: 79 \
`8_kyu`: 62 \
`7_kyu`: 13 \
`6_kyu`: 4 \
`5_kyu`: 0 \
Expand Down
1 change: 0 additions & 1 deletion kata.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
8 kyu - You only need one - Beginner - https://www.codewars.com/kata/57cc975ed542d3148f00015b
8 kyu - pick a set of first elements - https://www.codewars.com/kata/572b77262bedd351e9000076
8 kyu - Count the Monkeys! - https://www.codewars.com/kata/56f69d9f9400f508fb000ba7
8 kyu - Removing Elements - https://www.codewars.com/kata/5769b3802ae6f8e4890009d2
Expand Down

0 comments on commit 27c45a3

Please sign in to comment.