Completed challenge
This commit is contained in:
parent
a04ffff1b5
commit
2730659cb3
|
@ -6,10 +6,4 @@ Pretty simple, write a function called `reverseString` that returns it's input,
|
||||||
reverseString('hello there') // returns 'ereht olleh'
|
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.
|
|
|
@ -1,5 +1,9 @@
|
||||||
const reverseString = function(word) {
|
const reverseString = function(word) {
|
||||||
|
return word
|
||||||
|
.split('')
|
||||||
|
.splice('')
|
||||||
|
.reverse()
|
||||||
|
.join('');
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = reverseString
|
module.exports = reverseString
|
||||||
|
|
|
@ -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')
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue