Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions katas/make-palindrome/make-palindrom.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
function makePalindrome(text){
// ...
}
16 changes: 16 additions & 0 deletions katas/make-palindrome/make-palindrom_test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
describe('makePalindrome function', function() {

it('should return existing palindromes without modification', function() {
expect(makePalindrome('a')).toBe('a');
expect(makePalindrome('radar')).toBe('radar');
expect(makePalindrome('racecar')).toBe('racecar');
});

it('expand strings to form palindromes', function() {
expect(makePalindrome('ab')).toBe('aba');
expect(makePalindrome('abb')).toBe('abba');
expect(makePalindrome('abc')).toBe('abcba');
expect(makePalindrome('rad')).toBe('radar');
expect(makePalindrome('race')).toBe('racecar');
});
});
22 changes: 22 additions & 0 deletions katas/make-palindrome/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
####Description:

Write a function makePalindrome that takes a string as the argument and then returns the shortest possible palindrome made from that string without modifying the original string.
If more than one palindrome can be made, the function should return the solution where the given string appears at the beginning of the palindrome.

Only single word strings will be passed as arguments to the function.

####Example:

```js
makePalindrome('a') --> 'a'
makePalindrome('ab') --> 'aba'
makePalindrome('abc') --> 'abcba'
makePalindrome('race') --> 'racecar'
makePalindrome('leveled') --> 'deleveled'
```

See [tests in make-palindrom_test.js](https://github.com/AlexVvx/code-wars/blob/master/katas/make-palindrom/make-palindrom_test.js)

#####[Original Kata](https://www.codewars.com/kata/make-a-palindrome)

Good luck