From b245fd21329df9dc45def253884d0a7421130aaa Mon Sep 17 00:00:00 2001 From: seagreenmedia Date: Sun, 21 Feb 2021 23:32:14 -0500 Subject: [PATCH] final --- .DS_Store | Bin 0 -> 6148 bytes Day01/Problem01.js | 71 +++++++++++++++++----------------------- Day01/Problem01.test.js | 6 ++-- 3 files changed, 33 insertions(+), 44 deletions(-) create mode 100644 .DS_Store diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..92e6c2604eda2835cae1eb7c965b3108ea68c5cb GIT binary patch literal 6148 zcmeHKI|>3Z5S{S@f{mqRj-WRPvYx;TCv<+(hXZ$8bk*lD4>fyqlI^Ahrk zogER;)pfrVnTf~*ZYU2M`eys)JsV_1fpDC$ylpP0WTFn9|993kw6x%U#lVgX=H zYy%O2X;6Vd)od{|=!lohtBGx3&_%QP(7ai*Ls7pS=NC^Gt$`e=02SyeFpTBQ>i-)4 zrvLAfxS|47;I9 longestWord.length) { + longestWord = string[i]; + } + } + return longestWord; } - /** - * Have the swapCase(String input) take the input parameter and swap the case of each - * character. For example: if str is "Hello World" the output should be hELLO wORLD. - * Let numbers and symbols stay the way they are. - */ - swapCase(str) { - // code goes here - return null; + SwapCase(str) { + let newStr = ""; + for (let i = 0; i < str.length; i++) { + if (str[i] === str[i].toLowerCase()) { + newStr += str[i].toUpperCase(); + } else { + newStr += str[i].toLowerCase(); + } + } + return newStr; } - } module.exports = Problem; \ No newline at end of file diff --git a/Day01/Problem01.test.js b/Day01/Problem01.test.js index 3623ab2..14d6d33 100644 --- a/Day01/Problem01.test.js +++ b/Day01/Problem01.test.js @@ -55,7 +55,7 @@ test("firstReverse test01", () => { test("firstReverse test02", () => { let problem = new Problem(); - let expected = "eiD syobwoC eiD ,ylF selgaE ylF"; + let expected = "eiD syobwoC eiD ,ylF selgaE ylF"; let actual = problem.firstReverse("Fly Eagles Fly, Die Cowboys Die"); @@ -87,7 +87,7 @@ test("swapCase test01", () => { let problem = new Problem(); let expected = "hELLO-lol"; - let actual = problem.swapCase("Hello-LOL"); + let actual = problem.SwapCase("Hello-LOL"); expect(actual).toEqual(expected); }); @@ -97,7 +97,7 @@ test("swapCase test02", () => { let problem = new Problem(); let expected = "sUP dude!!?"; - let actual = problem.swapCase("Sup DUDE!!?"); + let actual = problem.SwapCase("Sup DUDE!!?"); expect(actual).toEqual(expected); }); \ No newline at end of file