From 5d6a44239fdf986a28f0e970b002ee9346f69b07 Mon Sep 17 00:00:00 2001 From: taylorhollins <74632541+taylorhollins@users.noreply.github.com> Date: Thu, 14 Jan 2021 20:57:45 -0500 Subject: [PATCH] complete --- basicMath/MathUtilities.js | 8 ++-- basicMath/MathUtilities.test.js | 2 +- strangerStrings/StrangerStrings.js | 51 +++++++++++++++++++------ strangerStrings/StrangerStrings.test.js | 6 +-- 4 files changed, 48 insertions(+), 19 deletions(-) diff --git a/basicMath/MathUtilities.js b/basicMath/MathUtilities.js index 705dd88..5cdc657 100644 --- a/basicMath/MathUtilities.js +++ b/basicMath/MathUtilities.js @@ -2,19 +2,19 @@ class MathUtilities { add(baseValue, valueToAdd){ - return -1; + return baseValue + valueToAdd; } subtract(baseValue, valueToAdd){ - return -1; + return baseValue - valueToAdd; } divide(baseValue, valueToAdd){ - return -1; + return baseValue / valueToAdd; } multiply(baseValue, valueToAdd){ - return -1; + return baseValue * valueToAdd; } } diff --git a/basicMath/MathUtilities.test.js b/basicMath/MathUtilities.test.js index 2d37cf1..bf0c9b2 100644 --- a/basicMath/MathUtilities.test.js +++ b/basicMath/MathUtilities.test.js @@ -74,7 +74,7 @@ test("Test 2 Integer Division", () => { let addedValue = 1; // When - let expected = 127; + let expected = 2; let actual = math.divide(baseValue, addedValue); //Then expect(actual).toEqual(expected); diff --git a/strangerStrings/StrangerStrings.js b/strangerStrings/StrangerStrings.js index 7fb3629..a23a671 100644 --- a/strangerStrings/StrangerStrings.js +++ b/strangerStrings/StrangerStrings.js @@ -1,35 +1,64 @@ class StrangerStrings { getHelloWorld(){ - return null; + let helloWorld = "Hello World" + return helloWorld; } concatenation(firstSegment, secondSegment){ - return null; + return firstSegment + secondSegment; } getPrefix(input){ - return null; + + /* let FirstLetter = input[0] + let SecondLetter = input [1] + let ThirdLetter = input [2] + return FirstLetter + SecondLetter + ThirdLetter; */ + return input.substr(0,3); } getSuffix(input){ - return null; + + let FourthLetter = input[input.length - 3]; + let FifthLetter = input[input.length - 2]; + let lastLetter = input[input.length - 1]; + return FourthLetter + FifthLetter + lastLetter; + } getMiddleCharacter(input){ - return null; + let inputLength = input.length; + let middle = Math.floor(inputLength/2); + if (inputLength % 2 == 0){ + // if even + return input[middle - 1] + input[middle]; + } else { + //if odd + return input[middle]; + } } - getFirstWord(input){ - return null; + getFirstWord(inputValue){ + let x = inputValue.split(" "); + let firstWord = x[0]; + return firstWord; } - getSecondWord(spaceDelimnatedInput){ - return null; + getSecondWord(inputValue){ + let x = inputValue.split(" "); + let secondWord = x[1]; + return secondWord; } - reverse(input){ - return null; + reverse(inputValue){ + let x = inputValue.split(""); + // x = [w,u,t,a,n,g,c,l,a,n] + let rev = x.reverse(); + // rev= n,a,l,c,g,n,a,t,u,w + let together = rev.join(""); + // join = nalcgnatuw + return together; } } diff --git a/strangerStrings/StrangerStrings.test.js b/strangerStrings/StrangerStrings.test.js index 59da8fa..53c4706 100644 --- a/strangerStrings/StrangerStrings.test.js +++ b/strangerStrings/StrangerStrings.test.js @@ -58,10 +58,10 @@ test("return the last 3 characters of `input`", () => { }); -test("return the middle character of `inputValue`", () => { +test("return the middle character of `input`", () => { // Given let strangerStrings = new StrangerStrings(); - let inputValue = 'MethodMan'; + let input = 'MethodMan'; let expected = "o"; @@ -76,7 +76,7 @@ test("return the first sequence of characters", () => { // Given let strangerStrings = new StrangerStrings(); let inputValue = 'Wutang Clan'; - +// inputValue=[Wutang, Clan] let expected = "Wutang";