Skip to content

Commit d04360c

Browse files
committed
makes code review suggestions
1 parent 05427e2 commit d04360c

3 files changed

Lines changed: 17 additions & 65 deletions

File tree

src/arrays.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ const reverseWordsInArray = strings => {
4444

4545
const onlyEven = numbers => {
4646
return numbers.filter(numbers => numbers % 2 === 0);
47-
4847
};
4948

5049
const removeNthElement2 = (index, array) => {

src/booleans.js

Lines changed: 13 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,21 @@
11
function negate(a) {
2-
if (a === false) {
3-
return true;
4-
}
5-
return false;
2+
return !a;
63
}
74

85
function both(a, b) {
9-
if (a === true && b === true) {
10-
return true;
11-
}
12-
return false;
6+
return a && b;
137
}
148

159
function either(a, b) {
16-
if (a === true || b === true) {
17-
return true;
18-
}
19-
return false;
10+
return a || b;
2011
}
2112

2213
function none(a, b) {
23-
if (a === false && b === false) {
24-
return true;
25-
}
26-
return false;
14+
return !a && !b;
2715
}
2816

2917
function one(a, b) {
30-
if ((a === true && b === false) || (a === false && b === true)) {
31-
return true;
32-
}
33-
return false;
18+
return (a && !b) || (!a && b);
3419
}
3520

3621
function truthiness(a) {
@@ -41,68 +26,39 @@ function truthiness(a) {
4126
}
4227

4328
function isEqual(a, b) {
44-
if (a === b) {
45-
return true;
46-
}
47-
return false;
29+
return a === b;
4830
}
4931

5032
function isGreaterThan(a, b) {
51-
if (a > b) {
52-
return true;
53-
}
54-
return false;
33+
return a > b;
5534
}
5635

5736
function isLessThanOrEqualTo(a, b) {
58-
if (a <= b) {
59-
return true;
60-
}
61-
return false;
37+
return a <= b;
6238
}
6339

6440
function isOdd(a) {
65-
if (a % 2 !== 0) {
66-
return true;
67-
}
68-
return false;
41+
return a % 2 !== 0;
6942
}
7043

7144
function isEven(a) {
72-
if (a % 2 === 0) {
73-
return true;
74-
}
75-
return false;
45+
return a % 2 === 0;
7646
}
7747

7848
function isSquare(a) {
79-
if (a >= 0 && Math.sqrt(a) % 1 === 0) {
80-
return true;
81-
}
82-
return false;
49+
return a >= 0 && Math.sqrt(a) % 1 === 0;
8350
}
8451

8552
function startsWith(char, string) {
86-
if (string.startsWith(char)) {
87-
return true;
88-
}
89-
return false;
53+
return string.startsWith(char);
9054
}
9155

9256
function containsVowels(string) {
93-
// return string === string.match(/[aeiou]/gi);
94-
if (string.match(/[aeiou]/gi)) {
95-
return true;
96-
}
97-
return false
57+
return !!string.match(/[aeiou]/i);
9858
}
9959

10060
function isLowerCase(string) {
10161
return string === string.toLowerCase();
102-
// if (string === string.toLowerCase()) {
103-
// return true;
104-
// }
105-
// return false;
10662
}
10763

10864
module.exports = {

src/objects.js

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const createPerson = (name, age) => {
2-
return { name: name, age: age };
2+
return { name, age };
33
};
44

55
const getName = object => {
@@ -15,10 +15,7 @@ const hasProperty = (property, object) => {
1515
};
1616

1717
const isOver65 = person => {
18-
if (person.age > 65) {
19-
return true;
20-
}
21-
return false;
18+
return person.age > 65;
2219
};
2320

2421
const getAges = people => {
@@ -43,8 +40,8 @@ const averageAge = people => {
4340

4441
const createTalkingPerson = (name, age) => {
4542
return {
46-
name: name,
47-
age: age,
43+
name,
44+
age,
4845
introduce: introduce => {
4946
return `Hi ${introduce}, my name is ${name} and I am ${age}!`;
5047
}

0 commit comments

Comments
 (0)