-
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
5 changed files
with
31 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 |
---|---|---|
@@ -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 |
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,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"); | ||
}); | ||
}); |
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,5 @@ | ||
export function abbrevName(name: string): string { | ||
const names = name.split(" ").map((name) => name[0].toUpperCase()); | ||
|
||
return names.join("."); | ||
} |
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