@@ -81,46 +81,46 @@ describe('Calculate the sum of array of numbers', () => {
8181 } ) ;
8282} ) ;
8383
84- describe ( 'Bonus: Calculate the sum' , ( ) => {
85- it ( 'should create a function named sum' , ( ) => {
86- expect ( typeof sum ) . toBe ( 'function' ) ;
87- } ) ;
88-
89- it ( 'should return zero if receives an empty array when called' , ( ) => {
90- expect ( sum ( [ ] ) ) . toBe ( 0 ) ;
91- } ) ;
92-
93- it ( 'should return the sum with one number array' , ( ) => {
94- expect ( sum ( [ 4 ] ) ) . toBe ( 4 ) ;
95- } ) ;
96-
97- it ( 'should return zero if all elements are zero' , ( ) => {
98- expect ( sum ( [ 0 , 0 , 0 , 0 , 0 ] ) ) . toBe ( 0 ) ;
99- } ) ;
100-
101- it ( 'should return the sum when passed array of numbers' , ( ) => {
102- expect ( sum ( [ 10 , 5 , 4 , 32 , 8 ] ) ) . toBe ( 59 ) ;
103- } ) ;
104-
105- it ( 'should return the sum when passed array of strings' , ( ) => {
106- expect ( sum ( [ 'ana' , 'marco' , 'nicolas' , 'tania' , 'ptwd' ] ) ) . toBe ( 24 ) ;
107- } ) ;
108-
109- it ( 'should return the sum when passed array of mixed strings and numbers - ' , ( ) => {
110- expect ( sum ( [ 6 , 12 , 'miami' , 1 , 'barca' , '200' , 'lisboa' , 8 , 10 ] ) ) . toBe ( 56 ) ;
111- } ) ;
112- it ( 'should return the sum when passed array of mixed strings, numbers and booleans - ' , ( ) => {
113- // false is counted as 0
114- expect ( sum ( [ 6 , 12 , 'miami' , 1 , 'barca' , '200' , 'lisboa' , 8 , false ] ) ) . toBe ( 46 ) ;
115- // true is counted as 1
116- expect ( sum ( [ 6 , 12 , 'miami' , 1 , 'barca' , '200' , 'lisboa' , 8 , true ] ) ) . toBe ( 47 ) ;
117- } ) ;
118- it ( 'should throw an error when unsupported data type (object or array) present in the array' , ( ) => {
119- expect ( ( ) => sum ( [ 6 , 12 , 'miami' , 1 , 'barca' , '200' , 'lisboa' , 8 , [ ] , { } ] ) ) . toThrow (
120- new Error ( "Unsupported data type sir or ma'am" )
121- ) ;
122- } ) ;
123- } ) ;
84+ // describe('Bonus: Calculate the sum', () => {
85+ // it('should create a function named sum', () => {
86+ // expect(typeof sum).toBe('function');
87+ // });
88+
89+ // it('should return zero if receives an empty array when called', () => {
90+ // expect(sum([])).toBe(0);
91+ // });
92+
93+ // it('should return the sum with one number array', () => {
94+ // expect(sum([4])).toBe(4);
95+ // });
96+
97+ // it('should return zero if all elements are zero', () => {
98+ // expect(sum([0, 0, 0, 0, 0])).toBe(0);
99+ // });
100+
101+ // it('should return the sum when passed array of numbers', () => {
102+ // expect(sum([10, 5, 4, 32, 8])).toBe(59);
103+ // });
104+
105+ // it('should return the sum when passed array of strings', () => {
106+ // expect(sum(['ana', 'marco', 'nicolas', 'tania', 'ptwd'])).toBe(24);
107+ // });
108+
109+ // it('should return the sum when passed array of mixed strings and numbers - ', () => {
110+ // expect(sum([6, 12, 'miami', 1, 'barca', '200', 'lisboa', 8, 10])).toBe(56);
111+ // });
112+ // it('should return the sum when passed array of mixed strings, numbers and booleans - ', () => {
113+ // // false is counted as 0
114+ // expect(sum([6, 12, 'miami', 1, 'barca', '200', 'lisboa', 8, false])).toBe(46);
115+ // // true is counted as 1
116+ // expect(sum([6, 12, 'miami', 1, 'barca', '200', 'lisboa', 8, true])).toBe(47);
117+ // });
118+ // it('should throw an error when unsupported data type (object or array) present in the array', () => {
119+ // expect(() => sum([6, 12, 'miami', 1, 'barca', '200', 'lisboa', 8, [], {}])).toThrow(
120+ // new Error("Unsupported data type sir or ma'am")
121+ // );
122+ // });
123+ // });
124124
125125describe ( 'Calculate the average of an array of numbers' , ( ) => {
126126 it ( 'should create a function named averageNumbers' , ( ) => {
@@ -164,22 +164,22 @@ describe('Calculate the average of an array of strings', () => {
164164 } ) ;
165165} ) ;
166166
167- describe ( 'Bonus: Calculate the average of a mixed elements array' , ( ) => {
168- it ( 'should create a function named avg' , ( ) => {
169- expect ( typeof avg ) . toBe ( 'function' ) ;
170- } ) ;
167+ // describe('Bonus: Calculate the average of a mixed elements array', () => {
168+ // it('should create a function named avg', () => {
169+ // expect(typeof avg).toBe('function');
170+ // });
171171
172- it ( 'should return null if receives an empty array when called' , ( ) => {
173- expect ( avg ( [ ] ) ) . toBe ( null ) ;
174- } ) ;
172+ // it('should return null if receives an empty array when called', () => {
173+ // expect(avg([])).toBe(null);
174+ // });
175175
176- it ( 'should return the average of the array' , ( ) => {
177- // false is counted as 0
178- expect ( avg ( [ 6 , 12 , 'miami' , 1 , 'barca' , '200' , 'lisboa' , 8 , false ] ) ) . toBe ( 5.11 ) ;
179- // true is counted as 1
180- expect ( avg ( [ 6 , 12 , 'miami' , 1 , 'barca' , '200' , 'lisboa' , 8 , true ] ) ) . toBe ( 5.22 ) ;
181- } ) ;
182- } ) ;
176+ // it('should return the average of the array', () => {
177+ // // false is counted as 0
178+ // expect(avg([6, 12, 'miami', 1, 'barca', '200', 'lisboa', 8, false])).toBe(5.11);
179+ // // true is counted as 1
180+ // expect(avg([6, 12, 'miami', 1, 'barca', '200', 'lisboa', 8, true])).toBe(5.22);
181+ // });
182+ // });
183183
184184describe ( 'Unique array' , ( ) => {
185185 it ( 'should create a function named uniquifyArray' , ( ) => {
@@ -266,60 +266,60 @@ describe('Count repetition', () => {
266266 } ) ;
267267} ) ;
268268
269- describe ( 'Bonus Quest - greatestProduct' , ( ) => {
270- it ( 'should create a function named greatestProduct' , ( ) => {
271- expect ( typeof greatestProduct ) . toBe ( 'function' ) ;
272- } ) ;
273-
274- it ( 'should return 1 (one) when all numbers of the arrays are 1' , ( ) => {
275- let matrix = [
276- [ 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 ] ,
277- [ 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 ] ,
278- [ 1 , 1 , 1 , 1 , 1 , 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 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 ] ,
319- [ 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 ] ,
320- [ 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 ] ,
321- [ 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 ]
322- ] ;
323- expect ( greatestProduct ( matrix ) ) . toBe ( 16 ) ;
324- } ) ;
325- } ) ;
269+ // describe('Bonus Quest - greatestProduct', () => {
270+ // it('should create a function named greatestProduct', () => {
271+ // expect(typeof greatestProduct).toBe('function');
272+ // });
273+
274+ // it('should return 1 (one) when all numbers of the arrays are 1', () => {
275+ // let matrix = [
276+ // [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
277+ // [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
278+ // [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
279+ // [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
280+ // [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
281+ // [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
282+ // [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
283+ // [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
284+ // [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
285+ // [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
286+ // [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
287+ // [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
288+ // [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
289+ // [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
290+ // [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
291+ // [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
292+ // [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
293+ // [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
294+ // [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
295+ // [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
296+ // ];
297+ // expect(greatestProduct(matrix)).toBe(1);
298+ // });
299+
300+ // it('should return 16 when all the numbers of the arrays are 2', () => {
301+ // let matrix = [
302+ // [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],
303+ // [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],
304+ // [2, 2, 2,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2],
320+ // [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],
321+ // [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]
322+ // ];
323+ // expect(greatestProduct(matrix)).toBe(16);
324+ // });
325+ // });
0 commit comments