Skip to content

Commit

Permalink
Abbreviate a Two Word Name
Browse files Browse the repository at this point in the history
  • Loading branch information
PheRum committed Jun 13, 2024
1 parent 5627ff8 commit 5a2c35d
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 4 deletions.
13 changes: 13 additions & 0 deletions 8_kyu/Abbreviate a Two Word Name/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
## Abbreviate a Two Word Name

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

Write a function to convert a name into initials. This kata strictly takes two words with one space in between them.

The output should be two capital letters with a dot separating them.

It should look like this:

Sam Harris => S.H

patrick feeney => P.F
11 changes: 11 additions & 0 deletions 8_kyu/Abbreviate a Two Word Name/index.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { abbrevName } from "./index";

describe("Tests", () => {
it("abbrevName", () => {
expect(abbrevName("Sam Harris")).toBe("S.H");
expect(abbrevName("Patrick Feenan")).toBe("P.F");
expect(abbrevName("Evan Cole")).toBe("E.C");
expect(abbrevName("P Favuzzi")).toBe("P.F");
expect(abbrevName("David Mendieta")).toBe("D.M");
});
});
5 changes: 5 additions & 0 deletions 8_kyu/Abbreviate a Two Word Name/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export function abbrevName(name: string): string {
const names = name.split(" ").map((name) => name[0].toUpperCase());

return names.join(".");
}
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`: 68 \
`8_kyu`: 51 \
`Total`: 69 \
`8_kyu`: 52 \
`7_kyu`: 13 \
`6_kyu`: 4 \
`5_kyu`: 0 \
Expand Down
2 changes: 0 additions & 2 deletions kata.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
8 kyu - Abbreviate a Two Word Name - https://www.codewars.com/kata/57eadb7ecd143f4c9c0000a3
8 kyu - Multiply the number - https://www.codewars.com/kata/5708f682c69b48047b000e07
8 kyu - Find out whether the shape is a cube - https://www.codewars.com/kata/58d248c7012397a81800005c
8 kyu - Grasshopper - Summation - https://www.codewars.com/kata/55d24f55d7dd296eb9000030
Expand Down Expand Up @@ -85,4 +84,3 @@
8 kyu - Invert values - https://www.codewars.com/kata/5899dc03bc95b1bf1b0000ad
8 kyu - Filter out the geese - https://www.codewars.com/kata/57ee4a67108d3fd9eb0000e7
8 kyu - Beginner - Reduce but Grow - https://www.codewars.com/kata/57f780909f7e8e3183000078
8 kyu - Multiply - https://www.codewars.com/kata/50654ddff44f800200000004

0 comments on commit 5a2c35d

Please sign in to comment.