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
14 changes: 12 additions & 2 deletions solutions/64.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const reverseInput = (string) => {
newString += string[i];
};
return newString;
}
};

/**
* @param {string} sentence - a sentence
Expand All @@ -38,6 +38,16 @@ const solution = (sentence) => {
return result.join(' ');
};

const solution2 = (actual) => {
let splitArr = actual.split(' ');
for (let i=0; i<splitArr.length/2; i++) {
let temp = splitArr[i];
splitArr[i] = splitArr[splitArr.length-i-1];
splitArr[splitArr.length-i-1] = temp;
}
actual = splitArr.join(' ');
return actual;
};
module.exports = {
solution
solution, solution2,
};
20 changes: 15 additions & 5 deletions solutions/yourSolution.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
// Name
// Problem Description
// Phillip Kelley-Dotson
// Arrange numbers and strings into ascending order.

const solution3 = (actual) => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you should not commit anything in yourSolution.js

if(/^[a-zA-Z]+$/.test(actual[0]) === true){ actual.sort();
return actual;
} else {
actual.sort(function (a,b){
return a-b;
});
return actual;
}
};


const yourSolution = () => {
};

module.exports = {
yourSolution,
solution3,
};
10 changes: 9 additions & 1 deletion test/5.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const expect = require('chai').expect;
let solution = require('../solutions/5').solution;
let solution2 = require('../solutions/5').solution2;
let solution3 = require('../solutions/yourSolution').solution3;

describe('sort arrays', () => {
// solution tests
Expand Down Expand Up @@ -47,5 +48,12 @@ describe('sort arrays', () => {
const actual = [57];
const expected = [57];
expect(solution2(actual)).eql(expected);
});
});
// for solution3
it.only('solution2 - array should have numbers in ascending order - single',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why are you duplicating a test case that is already written in line 30?

() => {
const actual = [1, 5, 31, 57, 2, 0];
const expected = [0, 1, 2, 5, 31, 57];
expect(solution3(actual)).eql(expected);
});
});
6 changes: 5 additions & 1 deletion test/64.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const expect = require('chai').expect;
let solution = require('../solutions/64').solution;
// solution = require('./yourSolution').solution;
let solution2 = require('../solutions/64').solution2;

describe('reverse word order in a sentence', () => {
it('should reverse the word order', () => {
Expand All @@ -9,4 +9,8 @@ describe('reverse word order in a sentence', () => {
it('should return I', () => {
expect(solution('I')).eql('I');
});
it.only('should reverse word order', () => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is this file doing in your MR to submit solution to #5 ?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

expect(solution2('happy goes it')).eql('it goes happy');

});
});