From a707c4bd2eb7d3663f4cd7a309d75fe12fbc535b Mon Sep 17 00:00:00 2001 From: Nick Satinover Date: Wed, 13 Jan 2021 19:46:34 -0500 Subject: [PATCH 1/2] passed StrangerStrings.test.js --- strangerStrings/StrangerStrings.js | 22 +++++++++++++--------- strangerStrings/StrangerStrings.test.js | 2 +- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/strangerStrings/StrangerStrings.js b/strangerStrings/StrangerStrings.js index 7fb3629..ff2e951 100644 --- a/strangerStrings/StrangerStrings.js +++ b/strangerStrings/StrangerStrings.js @@ -1,35 +1,39 @@ class StrangerStrings { getHelloWorld(){ - return null; + return "Hello World"; } concatenation(firstSegment, secondSegment){ - return null; + return firstSegment.concat(secondSegment); } getPrefix(input){ - return null; + return input.substring( 0, (input.length / 2) ); } getSuffix(input){ - return null; + return input.substring( (input.length / 2), ( input.length)); } getMiddleCharacter(input){ - return null; + return input[ + input.length % 2 == 0 ? ( input.length / 2 ) : ( (input.length - 1) / 2 ) + ]; } getFirstWord(input){ - return null; + const arr = input.split(' '); + return arr[0]; } - getSecondWord(spaceDelimnatedInput){ - return null; + getSecondWord(spaceDeliminatedInput){ + const arr = spaceDeliminatedInput.split(' '); + return arr[1]; } reverse(input){ - return null; + return input.split('').reverse().join(''); } } diff --git a/strangerStrings/StrangerStrings.test.js b/strangerStrings/StrangerStrings.test.js index 59da8fa..dbfbeb7 100644 --- a/strangerStrings/StrangerStrings.test.js +++ b/strangerStrings/StrangerStrings.test.js @@ -67,7 +67,7 @@ test("return the middle character of `inputValue`", () => { // When - let actual = strangerStrings.getMiddleCharacter(input); + let actual = strangerStrings.getMiddleCharacter(inputValue); //Then expect(actual).toEqual(expected); }); From 1967e42f7d0ddb5ba1eaf374938211265fecde93 Mon Sep 17 00:00:00 2001 From: Nick Satinover Date: Wed, 13 Jan 2021 20:03:41 -0500 Subject: [PATCH 2/2] Test 2 Integer Division - replaced expected. MathUtilites.js completed --- basicMath/MathUtilities.js | 8 ++++---- basicMath/MathUtilities.test.js | 2 +- 2 files changed, 5 insertions(+), 5 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);