-
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.
Printing Array elements with Comma delimiters
- Loading branch information
Showing
4 changed files
with
27 additions
and
2 deletions.
There are no files selected for viewing
15 changes: 15 additions & 0 deletions
15
8_kyu/Printing Array elements with Comma delimiters/README.md
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,15 @@ | ||
## Printing Array elements with Comma delimiters | ||
|
||
https://www.codewars.com/kata/56e2f59fb2ed128081001328 | ||
|
||
Input: Array of elements | ||
|
||
["h","o","l","a"] | ||
|
||
Output: String with comma delimited elements of the array in th same order. | ||
|
||
"h,o,l,a" | ||
|
||
Note: if this seems too simple for you try the next level | ||
|
||
Note2: the input data can be: boolean array, array of objects, array of string arrays, array of number arrays... 😕 |
7 changes: 7 additions & 0 deletions
7
8_kyu/Printing Array elements with Comma delimiters/index.test.ts
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,7 @@ | ||
import { printArray } from "./index"; | ||
|
||
describe("Tests", () => { | ||
it("printArray", () => { | ||
expect(printArray([2, 4, 5, 2])).toBe("2,4,5,2"); | ||
}); | ||
}); |
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 printArray(array: number[]): string { | ||
return array.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