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
67 changes: 52 additions & 15 deletions strangerStrings/StrangerStrings.js
Original file line number Diff line number Diff line change
@@ -1,35 +1,72 @@
class StrangerStrings {

getHelloWorld(){
return null;
return "Hello World";
}

concatenation(firstSegment, secondSegment){
return null;
return firstSegment + secondSegment;
}

getPrefix(input){
return null;
getPrefix(input) {
//Goal: Get first 3 letters of the input word
// 1. Get the 1st letter
let firstLetter = input.charAt(0);
// 2. Get the 2nd letter
let secondLetter = input.charAt(1);
// 3. Get the 3rd letter
let thirdLetter = input.charAt(2);
// 4. Reassemble
let answer = firstLetter + secondLetter + thirdLetter;
return answer;
//return input.substring(0, 3);
}

getSuffix(input){
return null;
getSuffix(input) {
//Goal: Get last 3 letters of the input word
// return input.substring(input.length-3, input.length);

// 1. Get the last letter
let firstLetter = input.charAt(input.length-1);
// // 2. Get the 2nd to the last letter
let secondLetter = input.charAt(input.length-2);
// // 3. Get the 3rd to the last letter
let thirdLetter = input.charAt(input.length-3);
// // 4. Reassemble
let answer = thirdLetter + secondLetter + firstLetter;
return answer;
// return thirdLetter + secondLetter + firstLetter;

}

getMiddleCharacter(input){
return null;
getMiddleCharacter(inputValue) {
let position;
let length;
//If the word has an even number of characters divide by 2
//Otherwise if the word has an odd number of characters length -1 and divide by 2
if (inputValue.length % 2 == 0) {
position = inputValue.length / 2 - 1;
length = 2;
} else {
position = (inputValue.length - 1) / 2;
length = 1;
}
return inputValue.substring(position, position + length);
}

getFirstWord(input){
return null;
getFirstWord(inputValue) {
//return input.slice(input.length - 11,input.length - 5);
// return inputValue.substr[(0, )];
let firstWord = inputValue.split(' ');
return firstWord[0];
}

getSecondWord(spaceDelimnatedInput){
return null;
getSecondWord(inputValue){
let secondWord = inputValue.split(' ');
return secondWord[1];
}

reverse(input){
return null;
reverse(inputValue){
return inputValue.split('').reverse('').join('');
}
}

Expand Down
9 changes: 4 additions & 5 deletions strangerStrings/StrangerStrings.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { TestScheduler } = require('jest');
// const { TestScheduler } = require('jest');
const StrangerStrings = require('./StrangerStrings');


Expand Down Expand Up @@ -46,9 +46,9 @@ test("return the first 3 characters of `input`", () => {
test("return the last 3 characters of `input`", () => {
// Given
let strangerStrings = new StrangerStrings();
let input = 'Wutang';
let input = 'WutangForever';

let expected = "ang";
let expected = "ver";


// When
Expand All @@ -65,9 +65,8 @@ test("return the middle character of `inputValue`", () => {

let expected = "o";


// When
let actual = strangerStrings.getMiddleCharacter(input);
let actual = strangerStrings.getMiddleCharacter(inputValue);
//Then
expect(actual).toEqual(expected);
});
Expand Down