finished reverseString.js exercise

This commit is contained in:
Denzel 2019-12-31 16:16:07 +08:00
parent daeb889802
commit 25625f266b
2 changed files with 8 additions and 6 deletions

View File

@ -1,5 +1,7 @@
const reverseString = function() { const reverseString = function(string) {
const arrayString = [...string];
const joinString = arrayString.reverse().join("");
return joinString;
} }
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')
}) })
}); });