From bf01232806f46ee3a466fa7d2f74f768ce41faff Mon Sep 17 00:00:00 2001 From: NetMan <13informatyka14@gmail.com> Date: Fri, 5 Jan 2024 20:51:18 +0100 Subject: [PATCH] Passed all tests for exercise 03 --- 03_reverseString/reverseString.js | 8 ++++++-- 03_reverseString/reverseString.spec.js | 6 +++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/03_reverseString/reverseString.js b/03_reverseString/reverseString.js index f6790f0..28111ae 100644 --- a/03_reverseString/reverseString.js +++ b/03_reverseString/reverseString.js @@ -1,5 +1,9 @@ -const reverseString = function() { - +const reverseString = function(string) { + let output = ""; + for (let i = 0; i < string.length; i++) { + output += string.charAt(string.length - i - 1); + } + return output; }; // 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('') }) });