-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
25 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters