-
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
4 changed files
with
32 additions
and
2 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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
## Well of Ideas - Easy Version | ||
|
||
https://www.codewars.com/kata/57f222ce69e09c3630000212 | ||
|
||
For every good kata idea there seem to be quite a few bad ones! | ||
|
||
In this kata you need to check the provided array (x) for good ideas 'good' and bad ideas 'bad'. If there are one or two good ideas, | ||
return 'Publish!', if there are more than 2 return 'I smell a series!'. If there are no good ideas, as is often the case, return 'Fail!'. |
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 @@ | ||
import { well } from "./index"; | ||
|
||
describe("Tests", () => { | ||
it("example", () => { | ||
expect(well(["bad", "bad", "bad"])).toBe("Fail!"); | ||
expect(well(["good", "bad", "bad", "bad", "bad"])).toBe("Publish!"); | ||
expect(well(["good", "bad", "bad", "bad", "bad", "good", "bad", "bad", "good"])).toBe("I smell a series!"); | ||
}); | ||
}); |
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,13 @@ | ||
type WellType = "good" | "bad"; | ||
|
||
export function well(x: WellType[]) { | ||
const good = x.filter((n) => n === "good").length; | ||
|
||
if (good && good <= 2) { | ||
return "Publish!"; | ||
} | ||
if (good > 2) { | ||
return "I smell a series!"; | ||
} | ||
return "Fail!"; | ||
} |
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