Skip to content

Commit 7db1d0f

Browse files
committed
fix: linter fixes
1 parent c418ee9 commit 7db1d0f

File tree

2 files changed

+186
-24
lines changed

2 files changed

+186
-24
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,74 +1,73 @@
11
const findMaxConsecutive1s = require('.');
22

3-
describe('Find max consecutive 1s', function() {
4-
it('returns 0 for an empty array', function() {
3+
describe('Find max consecutive 1s', () => {
4+
it('returns 0 for an empty array', () => {
55
const inputArr = [];
66
const expected = 0;
77

88
expect(findMaxConsecutive1s(inputArr)).toEqual(expected);
99
});
1010

11-
it('returns 0 for an array containing a single 0', function() {
11+
it('returns 0 for an array containing a single 0', () => {
1212
const inputArr = [0];
1313
const expected = 0;
1414

1515
expect(findMaxConsecutive1s(inputArr)).toEqual(expected);
1616
});
1717

18-
it('returns 1 for an array containing a single 1', function() {
18+
it('returns 1 for an array containing a single 1', () => {
1919
const inputArr = [1];
2020
const expected = 1;
2121

2222
expect(findMaxConsecutive1s(inputArr)).toEqual(expected);
2323
});
2424

25-
it('returns 1 for an array containing a single 1 and 0', function() {
25+
it('returns 1 for an array containing a single 1 and 0', () => {
2626
const inputArr = [1, 0];
2727
const expected = 1;
2828

2929
expect(findMaxConsecutive1s(inputArr)).toEqual(expected);
3030
});
3131

32-
it('returns 1 for an array containing a single 0 and 1', function() {
32+
it('returns 1 for an array containing a single 0 and 1', () => {
3333
const inputArr = [0, 1];
3434
const expected = 1;
3535

3636
expect(findMaxConsecutive1s(inputArr)).toEqual(expected);
3737
});
3838

39-
it('returns 1 for a large alternating array of 1s and 0s', function() {
39+
it('returns 1 for a large alternating array of 1s and 0s', () => {
4040
const inputArr = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1];
4141
const expected = 1;
4242

4343
expect(findMaxConsecutive1s(inputArr)).toEqual(expected);
4444
});
4545

46-
it('returns 5 for increasing groups of 1s (max 5)', function() {
46+
it('returns 5 for increasing groups of 1s (max 5)', () => {
4747
const inputArr = [1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1];
4848
const expected = 5;
4949

5050
expect(findMaxConsecutive1s(inputArr)).toEqual(expected);
5151
});
5252

53-
it('returns 5 for decreasing groups of 1s (max 5)', function() {
53+
it('returns 5 for decreasing groups of 1s (max 5)', () => {
5454
const inputArr = [1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1];
5555
const expected = 5;
5656

5757
expect(findMaxConsecutive1s(inputArr)).toEqual(expected);
5858
});
5959

60-
it('returns 5 for an array of 5 1s', function() {
60+
it('returns 5 for an array of 5 1s', () => {
6161
const inputArr = [1, 1, 1, 1, 1];
6262
const expected = 5;
6363

6464
expect(findMaxConsecutive1s(inputArr)).toEqual(expected);
6565
});
6666

67-
it('skips 1s that are Strings', function() {
68-
const inputArr = [1, 1, "1"];
67+
it('skips 1s that are Strings', () => {
68+
const inputArr = [1, 1, '1'];
6969
const expected = 2;
7070

7171
expect(findMaxConsecutive1s(inputArr)).toEqual(expected);
7272
});
7373
});
74-

src/_Problems_/max-product-of-3-numbers/max-product-of-3-numbers.test.js

+174-11
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,200 @@
1-
const { maxProductof3Numbers, maxProductof3NumbersII } = require(".");
1+
const { maxProductof3Numbers, maxProductof3NumbersII } = require('.');
22

3-
describe("Maximum Product of three numbers", () => {
4-
it("throws an error with no Array is passed", () => {
3+
describe('Maximum Product of three numbers', () => {
4+
it('throws an error with no Array is passed', () => {
55
expect(() => {
6-
maxProductof3Numbers("xunda");
6+
maxProductof3Numbers('xunda');
77
}).toThrowError();
88
expect(() => {
9-
maxProductof3NumbersII("xunda");
9+
maxProductof3NumbersII('xunda');
1010
}).toThrowError();
1111
});
1212

13-
it("returns the product of an array with 3 numbers", () => {
13+
it('returns the product of an array with 3 numbers', () => {
1414
expect(maxProductof3Numbers([1, 2, 3])).toEqual(6);
1515
expect(maxProductof3NumbersII([1, 2, 3])).toEqual(6);
1616
});
1717

18-
it("returns the product of an array with positive and negative numbers", () => {
18+
it('returns the product of an array with positive and negative numbers', () => {
1919
expect(maxProductof3Numbers([-10, -10, 2, 3])).toEqual(300);
2020
expect(maxProductof3NumbersII([-10, -10, 2, 3])).toEqual(300);
2121
});
2222

23-
it("returns the product of an array with negative numbers", () => {
23+
it('returns the product of an array with negative numbers', () => {
2424
expect(maxProductof3Numbers([-10, -1, -2, -10])).toEqual(-20);
2525
expect(maxProductof3NumbersII([-10, -1, -2, -10])).toEqual(-20);
2626
});
2727

28-
it("returns the proper calculation if the array is large", () => {
29-
const largeArray = [100, 100, 100, 12, 3, 45, 4, 3, 7, 8, 1, 3, 7, 8, 1, 4, 3, 7, 8, 1, 3, 7, 8, 1, 12, 3, 45, 4, 3, 7, 8, 1, 3, 7, 8, 1, 4, 3, 7, 8, 1, 3, 7, 8, 1, 4, 3, 7, 8, 1, 3, 7, 8, 1, 12, 3, 45, 4, 3, 7, 8, 1, 3, 7, 8, 1, 4, 3, 7, 8, 1, 3, 7, 8, 45, 4, 3, 7, 8, 1, 3, 7, 8, 3, 45, 4, 3, 7, 8, 1, 3, 7, 8, 1, 4, 3, 7, 8, 1, 3, 7, 8, 1, 12, 3, 45, 4, 3, 7, 8, 1, 3, 7, 8, 1, 4, 3, 7, 8, 1, 3, 7, 8, 1, 4, 3, 7, 8, 1, 3, 7, 8, 1, 12, 3, 45, 4, 3, 7, 8, 1, 3, 7, 8, 1, 4, 3, 7, 8, 1, 3, 7, 8, 45, 4, 3, 7, 8, 1, 3, 7, 8];
28+
it('returns the proper calculation if the array is large', () => {
29+
const largeArray = [
30+
100,
31+
100,
32+
100,
33+
12,
34+
3,
35+
45,
36+
4,
37+
3,
38+
7,
39+
8,
40+
1,
41+
3,
42+
7,
43+
8,
44+
1,
45+
4,
46+
3,
47+
7,
48+
8,
49+
1,
50+
3,
51+
7,
52+
8,
53+
1,
54+
12,
55+
3,
56+
45,
57+
4,
58+
3,
59+
7,
60+
8,
61+
1,
62+
3,
63+
7,
64+
8,
65+
1,
66+
4,
67+
3,
68+
7,
69+
8,
70+
1,
71+
3,
72+
7,
73+
8,
74+
1,
75+
4,
76+
3,
77+
7,
78+
8,
79+
1,
80+
3,
81+
7,
82+
8,
83+
1,
84+
12,
85+
3,
86+
45,
87+
4,
88+
3,
89+
7,
90+
8,
91+
1,
92+
3,
93+
7,
94+
8,
95+
1,
96+
4,
97+
3,
98+
7,
99+
8,
100+
1,
101+
3,
102+
7,
103+
8,
104+
45,
105+
4,
106+
3,
107+
7,
108+
8,
109+
1,
110+
3,
111+
7,
112+
8,
113+
3,
114+
45,
115+
4,
116+
3,
117+
7,
118+
8,
119+
1,
120+
3,
121+
7,
122+
8,
123+
1,
124+
4,
125+
3,
126+
7,
127+
8,
128+
1,
129+
3,
130+
7,
131+
8,
132+
1,
133+
12,
134+
3,
135+
45,
136+
4,
137+
3,
138+
7,
139+
8,
140+
1,
141+
3,
142+
7,
143+
8,
144+
1,
145+
4,
146+
3,
147+
7,
148+
8,
149+
1,
150+
3,
151+
7,
152+
8,
153+
1,
154+
4,
155+
3,
156+
7,
157+
8,
158+
1,
159+
3,
160+
7,
161+
8,
162+
1,
163+
12,
164+
3,
165+
45,
166+
4,
167+
3,
168+
7,
169+
8,
170+
1,
171+
3,
172+
7,
173+
8,
174+
1,
175+
4,
176+
3,
177+
7,
178+
8,
179+
1,
180+
3,
181+
7,
182+
8,
183+
45,
184+
4,
185+
3,
186+
7,
187+
8,
188+
1,
189+
3,
190+
7,
191+
8,
192+
];
30193
expect(maxProductof3Numbers(largeArray)).toEqual(100 * 100 * 100);
31194
expect(maxProductof3NumbersII(largeArray)).toEqual(100 * 100 * 100);
32195
});
33196

34-
it("returns an error if there are less than 3 numbers", () => {
197+
it('returns an error if there are less than 3 numbers', () => {
35198
expect(() => {
36199
maxProductof3Numbers([-10, -1]);
37200
}).toThrowError();

0 commit comments

Comments
 (0)