diff --git a/katas/first-non-repeating-letter/first-non-repeating-letter.js b/katas/first-non-repeating-letter/first-non-repeating-letter.js new file mode 100644 index 0000000..1f92823 --- /dev/null +++ b/katas/first-non-repeating-letter/first-non-repeating-letter.js @@ -0,0 +1,3 @@ +function firstNonRepeatingLetter(string) { + // Add your code here +} diff --git a/katas/first-non-repeating-letter/first-non-repeating-letter_test.js b/katas/first-non-repeating-letter/first-non-repeating-letter_test.js new file mode 100644 index 0000000..29bc4ab --- /dev/null +++ b/katas/first-non-repeating-letter/first-non-repeating-letter_test.js @@ -0,0 +1,11 @@ +describe('FirstNonRepeatingLetter function', function() { + it('should return result correctly', function() { + expect(firstNonRepeatingLetter('a')).toEqual('a'); + expect(firstNonRepeatingLetter('stress')).toEqual('t'); + expect(firstNonRepeatingLetter('moonmen')).toEqual('e'); + }); + + it('should return empty string if string contains all repeating characters', function() { + expect(firstNonRepeatingLetter('aaaaaaa')).toEqual(''); + }); +}); diff --git a/katas/first-non-repeating-letter/readme.md b/katas/first-non-repeating-letter/readme.md new file mode 100644 index 0000000..3c4dea4 --- /dev/null +++ b/katas/first-non-repeating-letter/readme.md @@ -0,0 +1,23 @@ +####Description: + +Write a function named firstNonRepeatingCharacter that takes a string input, and returns the first character that is not repeated anywhere in the string. + +For example, if given the input 'stress', the function should return 't', since the letter t only occurs once in the string, and occurs first in the string. + +As an added challenge, upper- and lowercase letters are considered the same character, but the function should return the correct case for the initial letter. + +If a string contains all repeating characters, it should return the empty string (""). + +####Example: + +```js + +firstNonRepeatingCharacter('sTreSS') // 'T' + +``` + +See [tests in first-non-repeating-letter_test.js](https://github.com/AlexVvx/code-wars/tree/master/katas/first-non-repeating-letter/first-non-repeating-letter_test.js) + +Good luck + +#####[Original Kata](https://www.codewars.com/kata/first-non-repeating-letter)