Skip to content

Commit

Permalink
Stop gninnipS My sdroW!
Browse files Browse the repository at this point in the history
  • Loading branch information
PheRum committed Jun 15, 2024
1 parent 5e34207 commit 1511c6d
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 2 deletions.
11 changes: 11 additions & 0 deletions 6_kyu/Stop gninnipS My sdroW!/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
## Stop gninnipS My sdroW!

https://www.codewars.com/kata/5264d2b162488dc400000001

Write a function that takes in a string of one or more words, and returns the same string, but with all words that have five or more letters reversed (Just like the name of this Kata). Strings passed in will consist of only letters and spaces. Spaces will be included only when more than one word is present.

```js
"Hey fellow warriors" --> "Hey wollef sroirraw"
"This is a test --> "This is a test"
"This is another test" --> "This is rehtona test"
```
7 changes: 7 additions & 0 deletions 6_kyu/Stop gninnipS My sdroW!/index.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { spinWords } from "./index";

describe("Tests", () => {
it("example", () => {
expect(spinWords("Hey fellow warriors")).toBe("Hey wollef sroirraw");
});
});
8 changes: 8 additions & 0 deletions 6_kyu/Stop gninnipS My sdroW!/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export function spinWords(words: string): string {
const wordReverse = (w: string) => w.split("").reverse().join("");

return words
.split(" ")
.map((word) => (word.length >= 5 ? wordReverse(word) : word))
.join(" ");
}
1 change: 1 addition & 0 deletions 6_kyu/_example/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ import { example } from "./index";
describe("Tests", () => {
it("example", () => {
expect(example(1, 1)).toBe(2);
expect(example(1, 1)).toEqual(2);
});
});
1 change: 1 addition & 0 deletions 7_kyu/_example/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ import { example } from "./index";
describe("Tests", () => {
it("example", () => {
expect(example(1, 1)).toBe(2);
expect(example(1, 1)).toEqual(2);
});
});
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

### Katas solved

`Total`: 104 \
`Total`: 105 \
`8_kyu`: 87 \
`7_kyu`: 13 \
`6_kyu`: 4 \
`6_kyu`: 5 \
`5_kyu`: 0 \
`4_kyu`: 0 \
`3_kyu`: 0 \
Expand Down

0 comments on commit 1511c6d

Please sign in to comment.