Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions basicMath/MathUtilities.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

Expand Down
2 changes: 1 addition & 1 deletion basicMath/MathUtilities.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
61 changes: 50 additions & 11 deletions strangerStrings/StrangerStrings.js
Original file line number Diff line number Diff line change
@@ -1,35 +1,74 @@
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;
}

getSuffix(input){
return null;
// get the 3rd to last letter.
let thirdToLastLetter = input[input.length - 3];
// get the 2nd letter.
let secondToLastLetter = input[input.length - 2];
// get the last letter.
let lastLetter = input[input.length - 1];
return thirdToLastLetter + secondToLastLetter + lastLetter;

}

getMiddleCharacter(input){
return null;
//get input length
let inputLength = input.length;
//divide length by two to cut in half. Math.floor to round down since string is an odd number.
let middle = Math.floor(inputLength / 2);
//return middle of input value.
if (inputLength % 2 == 0){
// if even
return input[middle -1] + input[middle];
} else {
return input[middle];
}

}

getFirstWord(input){
return null;
getFirstWord(inputValue){
// split up the string using .split(). Turns a string into an array.
let x = inputValue.split(" ");
// get the first index of the array.
let firstWord = x[0];
// return the first word.
return firstWord;
}

getSecondWord(spaceDelimnatedInput){
return null;
getSecondWord(inputValue){
// turn input value into a string using .split()
let x = inputValue.split(" ");
// get the second index of the array.
let secondWord = x[1];
// return the second word.
return secondWord;
}

reverse(input){
return null;
reverse(inputValue){
// turn input value into a string using .split()
let x = inputValue.split("");
// reverse the array using .reverse()
let strToArray = x.reverse();
// turn the array back to a string with .join()
let backwardArray = strToArray.join("");
// return joined reversed string.
return backwardArray;
}
}

Expand Down
4 changes: 2 additions & 2 deletions strangerStrings/StrangerStrings.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down