From e96baedad15eef2fa71d608302b10871e523164d Mon Sep 17 00:00:00 2001 From: marleyrae Date: Mon, 19 Jun 2023 15:33:46 -0700 Subject: [PATCH] Make 03 tests pass --- 03_reverseString/reverseString.js | 8 +++++++- 03_reverseString/reverseString.spec.js | 6 +++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/03_reverseString/reverseString.js b/03_reverseString/reverseString.js index f6790f0..07e82d3 100644 --- a/03_reverseString/reverseString.js +++ b/03_reverseString/reverseString.js @@ -1,5 +1,11 @@ -const reverseString = function() { +const reverseString = function (string) { + let reversed = '' + Array.from(string).reverse().forEach(char => { + reversed += char + }) + + return reversed }; // Do not edit below this line diff --git a/03_reverseString/reverseString.spec.js b/03_reverseString/reverseString.spec.js index 8adb887..b51c50e 100644 --- a/03_reverseString/reverseString.spec.js +++ b/03_reverseString/reverseString.spec.js @@ -5,14 +5,14 @@ describe('reverseString', () => { expect(reverseString('hello')).toEqual('olleh'); }); - test.skip('reverses multiple words', () => { + test('reverses multiple words', () => { expect(reverseString('hello there')).toEqual('ereht olleh') }) - test.skip('works with numbers and punctuation', () => { + test('works with numbers and punctuation', () => { expect(reverseString('123! abc!')).toEqual('!cba !321') }) - test.skip('works with blank strings', () => { + test('works with blank strings', () => { expect(reverseString('')).toEqual('') }) });