You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -13,7 +13,6 @@ In this exercise you will apply:
13
13
14
14
Manipulating arrays in code is a very common operation. Whether you're 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're probably going to be modifying or manipulating an array in some way.
15
15
16
-
17
16
## Requirements
18
17
19
18
- Fork this repo
@@ -22,30 +21,34 @@ Manipulating arrays in code is a very common operation. Whether you're creating
22
21
## Submission
23
22
24
23
Upon completion, run the following commands:
24
+
25
25
```
26
26
$ git add .
27
27
$ git commit -m "done"
28
28
$ git push origin master
29
29
```
30
+
30
31
Create Pull Request so your TAs can check up your work.
31
32
32
-
## Testing Introduction
33
+
## Automated Testing Introduction
33
34
34
-
### What is testing?
35
+
### What is automated testing?
35
36
36
-
Software testing is a process of executing an application to validate and verify that it meets the business and technical requirements and works as expected.
37
+
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.
37
38
38
-
Testing is a process, not a single activity. So the process of designing tests early at the beginning of the development and the product's lifecycle can help to prevent deficiencies in the code or product design.
39
+
Testing should be viewed as a continuous process, not a discrete operation or single activity in the development lifecycle. Designing tests at the beginning of the product lifecycle can be help to mitigate common issues that arise when developing complex codebases.
39
40
40
-
We have created all the tests you need to create the solution, and you have to execute them all and create the code to accomplish all the requirements.
41
+
Having a strong _test suite_ can provide you ease of mind, since you'll be able to confidently improve upon your work while knowing that your not breaking a previously developed feature.
41
42
42
-
Tests prove that your code actually works in every situation in which it’s designed to work. Even when you are improving the design or creating new features, you can change your current code without breaking what already works.
43
+
### Testing labs
44
+
45
+
This lab, along with some of the labs you'll be working on during the bootcamp, has a complete test suite that is meant to ensure that your work fulfills the requirements we established.
Jasmine is an automated testing framework for JavaScript. It is designed to be used in BDD (behavior-driven development) programming which focuses more on the business value than on the technical details.
51
+
Jasmine is an automated testing framework for JavaScript. It is designed to be used in Behavior-driven Development (**BDD**) programming, which focuses more on the business value than on the technical details.
49
52
50
53
We have already included Jasmine in the project you just forked, so let's see how to use it to implement our code.
51
54
@@ -65,47 +68,38 @@ starter-code/
65
68
└─ SpecRunner.html
66
69
```
67
70
68
-
We will be working with the `functions-and-arrays.js` file inside the `src` folder. In the `jasmine` folder you can find all the files that compose Jasmine, that is already linked with the `SpecRunner.html` file.
71
+
We will be working with the `functions-and-arrays.js` file inside of the `src` folder. In the `jasmine` folder you can find all of the files that compose Jasmine, that is already linked with the `SpecRunner.html` file.
69
72
70
73
**Run tests**
71
74
72
-
Run the tests with Jasmine is super easy, you just have to open the `SpecRunner.html` file in your browser. You will find something like this:
75
+
Running automated tests with Jasmine is super easy. All you need to do is open the `SpecRunner.html` file in your browser. You will find something similar this:
You have to write your code on the `src/functions-and-arrays.js` file. Following the instructions, you should go step by step passing all the tests.
81
+
You should write your code on the `src/functions-and-arrays.js` file. By following the instructions for each iteration, you should go every test and make sure it's _passing_.
79
82
80
-
Do not rush to go through all of them at once, take your time to read carefully about what the iteration is asking you, and solve the errors one by one.
83
+
Do not rush. You should take your time to carefully read every iteration, and you should address the _breaking_ tests as you progress through the exercise.
81
84
82
-
When coding with tests, is super important to read and understand the errors we are having for each test, this way we will know what it expect from your code.
85
+
When coding with tests, it is super important that you carefully read and understand the errors you're getting, this way you'll know for sure what's expected from your code.
83
86
84
87
## Deliverables
85
88
86
89
Write your JavaScript in the provided `src/functions-and-arrays.js` file.
87
90
88
-
89
91
## Iteration #1: Find the maximum
90
92
91
-
Define a function `maxOfTwoNumbers` that takes two numbers as arguments and returns the largest.
93
+
Define a function `maxOfTwoNumbers` that takes two numbers as arguments and returns the largest.
92
94
93
95
## Iteration #2: Finding Longest Word
94
96
95
-
Write a function `findLongestWord` that takes an array of words and returns the longest one. If there are 2 with the same length, it should return the first occurrence.
97
+
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.
@@ -114,7 +108,7 @@ Calculating a sum is as simple as iterating over an array and adding each of the
114
108
115
109
<!-- Semantically [reduce](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/Reduce) is the best method to use for this, but you can use any loop we've discussed so far. -->
116
110
117
-
Create a `sumArray`function that takes an array of numbers as a parameter, and calculate the sum of all its numbers. Later in the course you will learn how to use some array methods and you won't have to do this process "manually".
111
+
Declare a function named `sumArray` that takes as an argument an array of numbers, and returns the sum of all of the numbers in the array. Later in the course we'll learn how to do this by using the `reduce` array method, which will make your work significantly easier.
Write a function `averageWordLength` that receives an array of words and calculate the average length of the words:
140
+
Declare a function named `averageWordLength` that receives as a single argument an array of words and returns the average length of the words:
147
141
148
142
**Starter Code**
149
143
150
144
```javascript
151
145
constwords= [
152
-
'seat',
153
-
'correspond',
154
-
'linen',
155
-
'motif',
156
-
'hole',
157
-
'smell',
158
-
'smart',
159
-
'chaos',
160
-
'fuel',
161
-
'palace'
146
+
'seat',
147
+
'correspond',
148
+
'linen',
149
+
'motif',
150
+
'hole',
151
+
'smell',
152
+
'smart',
153
+
'chaos',
154
+
'fuel',
155
+
'palace'
162
156
];
163
157
```
164
158
165
159
## Iteration #5: Unique Arrays
166
160
167
-
Take the following array, remove the duplicates, and return a new array. You're 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)function.
161
+
Take the following array, remove the duplicates, and return a new array. You're 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.
168
162
169
-
Do this in the form of a function `uniquifyArray` that receives an array of words as a parameter.
163
+
Do this in the form of a function `uniquifyArray` that receives an array of words as a argument.
170
164
171
165
**Starter Code**
172
166
@@ -184,16 +178,16 @@ const words = [
184
178
'simple',
185
179
'bring'
186
180
];
187
-
188
181
```
189
182
190
183
## Iteration #6: Finding Elements
191
184
192
185
Let's create a simple array search.
193
186
194
-
Write a function `doesWordExist` that will take in an array of words as one argument, and a word to search for as the other. Return `true` if it exists, otherwise, return `false`. **Don't** use `indexOf` for this one. :)
187
+
Declare a function named `doesWordExist` that will take in an array of words as one argument, and a word to search for as the other. Return `true` if it exists, otherwise, return `false`. **Don't** use `indexOf` for this one.
195
188
196
189
**Starter Code**
190
+
197
191
```javascript
198
192
constwords= [
199
193
'machine',
@@ -209,7 +203,7 @@ const words = [
209
203
210
204
## Iteration #7: Counting Repetition
211
205
212
-
Write a function `howManyTimes` that will take in an array of words as one argument, and a word to search for as the other. The function will return the number of times that word appears in the array.
206
+
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.
213
207
214
208
**Starter Code**
215
209
@@ -224,7 +218,7 @@ const words = [
224
218
'eating',
225
219
'matter',
226
220
'truth',
227
-
'disobedience'
221
+
'disobedience',
228
222
'matter'
229
223
];
230
224
```
@@ -233,31 +227,31 @@ const words = [
233
227
234
228
In the 20×20 grid below; What is the greatest product of four adjacent numbers in the same direction (up, down, left, right)?
235
229
236
-
Write a function `greatestProduct` to find the answer!
230
+
Declare a function named`greatestProduct` to find the answer!
0 commit comments