diff --git a/reverseString/README.md b/reverseString/README.md index 578adc1..e413dac 100644 --- a/reverseString/README.md +++ b/reverseString/README.md @@ -6,10 +6,4 @@ Pretty simple, write a function called `reverseString` that returns it's input, reverseString('hello there') // returns 'ereht olleh' ``` -You will notice in this exercise that there are multiple tests, after making the first one pass, enable the others one by one by deleting the `x` in front of the `it()` function. - - - - -## Hints -Strings in JavaScript cannot be reversed directly so you're going to have to split it into something else first.. do the reversal and then join it back together into a string. +You will notice in this exercise that there are multiple tests, after making the first one pass, enable the others one by one by deleting the `x` in front of the `it()` function. \ No newline at end of file diff --git a/reverseString/reverseString.js b/reverseString/reverseString.js index f7df953..6963531 100644 --- a/reverseString/reverseString.js +++ b/reverseString/reverseString.js @@ -1,5 +1,9 @@ const reverseString = function(word) { - + return word + .split('') + .splice('') + .reverse() + .join(''); } module.exports = reverseString diff --git a/reverseString/reverseString.spec.js b/reverseString/reverseString.spec.js index e48840c..a7a543e 100644 --- a/reverseString/reverseString.spec.js +++ b/reverseString/reverseString.spec.js @@ -5,11 +5,11 @@ describe('reverseString', function() { expect(reverseString('hello')).toEqual('olleh'); }); - xit('reverses multiple words', function() { + it('reverses multiple words', function() { expect(reverseString('hello there')).toEqual('ereht olleh') }) - xit('works with numbers and punctuation', function() { + it('works with numbers and punctuation', function() { expect(reverseString('123! abc!')).toEqual('!cba !321') }) });