Skip to content

Commit a879ee6

Browse files
committed
removing variable usage as variable used only once, unnecessary use of language vocabulary, test case repeated is duplicate
1 parent b9033d1 commit a879ee6

File tree

2 files changed

+8
-14
lines changed

2 files changed

+8
-14
lines changed

src/Arrays/index.js

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
1-
export const titleCaseString = data => {
2-
const x = data.toLowerCase();
3-
const pp = x.split(' ');
4-
return pp.map(word => word.charAt(0).toUpperCase() + word.slice(1)).join(' ');
5-
};
1+
export const titleCaseString = data =>
2+
data
3+
.toLowerCase()
4+
.split(' ')
5+
.map(word => `${word.charAt(0).toUpperCase()}${word.slice(1)}`)
6+
.join(' ');
67

7-
export const convertStringToArray = (para, removeSpaces = false) => {
8-
const arr = [...para];
9-
return (removeSpaces) ?
10-
arr.filter(item => item !== ' ') : arr;
11-
};
8+
export const convertStringToArray = (para, removeSpaces = false) =>
9+
removeSpaces ? [...para].filter(item => item !== ' ') : [...para];
1210

1311
export const countInstanceInArray = arr => arr.reduce((obj, item) => {
1412
if (!obj[item]) obj[item] = 0;

src/__tests__/index.test.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,6 @@ test('Capitalize First Character after Space', () => (
1919
expect(titleCaseString('hello world')).toBe('Hello World')
2020
));
2121

22-
test('Capitalize First Character after Space', () => (
23-
expect(titleCaseString('hello world')).toBe('Hello World')
24-
));
25-
2622
// String to Array //
2723

2824
test('Convert String to Array', () => (

0 commit comments

Comments
 (0)