Skip to content

Commit 8c6e7c8

Browse files
authored
Update README.md
1 parent de52ee0 commit 8c6e7c8

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

README.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
# LAB | JS Functions & Arrays
44

5+
<br>
6+
57
## Introduction
68

79
Manipulating arrays in code is a very common operation. Whether you are creating a total for a shopping cart, grabbing only the first names out of a list of people, or moving a piece on a chessboard, you are probably going to be modifying or manipulating an array in some way.
@@ -24,8 +26,12 @@ git push origin master
2426

2527
Create Pull Request so your TAs can check up your work.
2628

29+
<br>
30+
2731
## Automated Testing Introduction
2832

33+
<br>
34+
2935
### What is automated testing?
3036

3137
Automated software testing is the process of programmatically executing an application in order to validate and verify that it meets the business needs, as well as the technical requirements, and that it behaves as expected.
@@ -34,10 +40,14 @@ Testing should be viewed as a continuous process, not a discrete operation or si
3440

3541
Having strong _test suites_ can provide you ease of mind, since you will be able to confidently improve upon your work while knowing that your not breaking a previously developed feature.
3642

43+
<br>
44+
3745
### Testing labs
3846

3947
This lab, along with some of the labs you will be working on during the bootcamp, has a complete test suite that is meant to ensure that your work fulfills the requirements we established.
4048

49+
<br>
50+
4151
### Testing with Jest
4252

4353
Jest is an automated test-runner for JavaScript.
@@ -48,6 +58,8 @@ We will be working with the `src/functions-and-arrays.js` file. To run your test
4858

4959
Open the `lab-solution.html` file using the live server VSCode extension.
5060

61+
<br>
62+
5163
#### Pass the tests
5264

5365
You should work on the `src/functions-and-arrays.js` file. While following the instructions for each iteration, you should check every test and make sure it's _passing_, before moving on.
@@ -58,12 +70,18 @@ When coding with tests, it is super important that you carefully read and unders
5870

5971
Note that **you don't need to execute the functions yourself**, the tests are responsible for doing that. All you should do is declare them, make sure they deal with the parameters passed and that they return what is indicated on the iterations and in the test messages. For some iterations we provide you with a sample array, so that you can do some **manual** testing, if you wish.
6072

73+
<br>
74+
6175
## Instructions
6276

77+
<br>
78+
6379
### Iteration #1: Find the maximum
6480

6581
Define a function `maxOfTwoNumbers` that takes two numbers as arguments and returns the largest.
6682

83+
<br>
84+
6785
### Iteration #2: Find the longest word
6886

6987
Declare a function named `findLongestWord` that takes as an argument an array of words and returns the longest one. If there are 2 with the same length, it should return the first occurrence.
@@ -74,6 +92,8 @@ You can use the following array to test your solution:
7492
const words = ['mystery', 'brother', 'aviator', 'crocodile', 'pearl', 'orchard', 'crackpot'];
7593
```
7694

95+
<br>
96+
7797
### Iteration #3: Calculate the sum
7898

7999
Calculating a sum can be as simple as iterating over an array and adding each of the elements together.
@@ -86,6 +106,8 @@ You can use the following array to test your solution:
86106
const numbers = [6, 12, 1, 18, 13, 16, 2, 1, 8, 10];
87107
```
88108

109+
<br>
110+
89111
#### Bonus - Iteration #3.1: A generic `sum()` function
90112

91113
**The goal: Learn how to refactor your code.** :muscle:
@@ -104,6 +126,8 @@ const mixedArr = [6, 12, 'miami', 1, true, 'barca', '200', 'lisboa', 8, 10];
104126
// should return: 57
105127
```
106128

129+
<br>
130+
107131
### Iteration #4: Calculate the average
108132

109133
Calculating an average is an extremely common task. Let's practice it a bit.
@@ -113,6 +137,8 @@ Calculating an average is an extremely common task. Let's practice it a bit.
113137
1. Find the sum as we did in the first exercise (or how about reusing that the _sumNumbers()_?)
114138
2. Take that sum and divide it by the number of elements in the list.
115139

140+
<br>
141+
116142
#### Level 1: Array of numbers
117143

118144
Declare a function named `averageNumbers` that expects an array of numbers and returns the average of the numbers:
@@ -123,6 +149,8 @@ You can use the following array to test your solution:
123149
const numbers = [2, 6, 9, 10, 7, 4, 1, 9];
124150
```
125151

152+
<br>
153+
126154
#### Level 2: Array of strings
127155

128156
Declare a function named `averageWordLength` that receives as a single argument an array of words and returns the average length of the words:
@@ -133,6 +161,8 @@ You can use the following array to test your solution:
133161
const words = ['seat', 'correspond', 'linen', 'motif', 'hole', 'smell', 'smart', 'chaos', 'fuel', 'palace'];
134162
```
135163

164+
<br>
165+
136166
#### Bonus - Iteration #4.1: A generic `avg()` function
137167

138168
Create function `avg(arr)` that receives any mixed array and calculates average. Consider as mixed array an array filled with numbers and/or strings and/or booleans. We are following a similar logic to the one applied on the bonus iteration 4.1. :wink:
@@ -143,6 +173,8 @@ const mixedArr = [6, 12, 'miami', 1, true, 'barca', '200', 'lisboa', 8, 10];
143173
// should return: 5.7
144174
```
145175

176+
<br>
177+
146178
### Iteration #5: Unique arrays
147179

148180
Take the following array, remove the duplicates, and return a new array. You are more than likely going to want to check out the [`indexOf`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/indexOf) Array method.
@@ -167,6 +199,8 @@ const words = [
167199
];
168200
```
169201

202+
<br>
203+
170204
### Iteration #6: Find elements
171205

172206
Let's create a simple array search.
@@ -179,6 +213,8 @@ You can use the following array to test your solution:
179213
const words = ['machine', 'subset', 'trouble', 'starting', 'matter', 'eating', 'truth', 'disobedience'];
180214
```
181215

216+
<br>
217+
182218
### Iteration #7: Count repetition
183219

184220
Declare a function named `howManyTimes` that will take in an array of words as the first argument, and a word to search for as the second argument. The function will return the number of times that word appears in the array.
@@ -201,6 +237,8 @@ const words = [
201237
];
202238
```
203239

240+
<br>
241+
204242
### Bonus - Iteration #8: Product of adjacent numbers
205243

206244
What is the greatest product of four adjacent numbers? We consider adjacent any four numbers that are next to each other horizontally or vertically.
@@ -244,8 +282,12 @@ const matrix = [
244282
];
245283
```
246284

285+
<br>
286+
247287
### Bonus - Iteration #8.1: Product of diagonals
248288

249289
Following the logic you've used in iteration #8, declare a function called `greatestProductOfDiagonals(matrix)`. It takes a matrix as a parameter and returns the greatest product of any four values layed out diagonally, in either direction.
250290

291+
<br>
292+
251293
**Happy coding!** :heart:

0 commit comments

Comments
 (0)