Merge pull request #9 from BillalPatel/reverse-string

Starting challenge
This commit is contained in:
Billal Patel 2019-11-03 22:24:21 +00:00 committed by GitHub
commit 3feecab5eb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 11 deletions

View File

@ -7,9 +7,3 @@ 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. 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.

View File

@ -1,5 +1,9 @@
const reverseString = function() { const reverseString = function(word) {
return word
.split('')
.splice('')
.reverse()
.join('');
} }
module.exports = reverseString module.exports = reverseString

View File

@ -5,11 +5,11 @@ describe('reverseString', function() {
expect(reverseString('hello')).toEqual('olleh'); expect(reverseString('hello')).toEqual('olleh');
}); });
xit('reverses multiple words', function() { it('reverses multiple words', function() {
expect(reverseString('hello there')).toEqual('ereht olleh') 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') expect(reverseString('123! abc!')).toEqual('!cba !321')
}) })
}); });