-
Notifications
You must be signed in to change notification settings - Fork 0
/
solution0011.js
27 lines (24 loc) · 891 Bytes
/
solution0011.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
/*
8 kyu - Double Char
Given a string, you have to return a string in which each character (case-sensitive) is repeated once.
Examples (Input -> Output):
* "String" -> "SSttrriinngg"
* "Hello World" -> "HHeelllloo WWoorrlldd"
* "1234!_ " -> "11223344!!__ "
*/
function doubleChar(str) {
return str.split('').map(i => i + i).join('');
}
/*
Sample Tests:
describe("doubleChar", function() {
it("works for some examples", function() {
Test.assertEquals(doubleChar("abcd"), "aabbccdd");
Test.assertEquals(doubleChar("Adidas"), "AAddiiddaass");
Test.assertEquals(doubleChar("1337"), "11333377");
Test.assertEquals(doubleChar("illuminati"), "iilllluummiinnaattii");
Test.assertEquals(doubleChar("123456"), "112233445566");
Test.assertEquals(doubleChar("%^&*("), "%%^^&&**((");
});
});
*/