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
Copy file name to clipboardExpand all lines: README.md
+18-38Lines changed: 18 additions & 38 deletions
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@
4
4
5
5
## Introduction
6
6
7
-
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.
7
+
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.
8
8
9
9
## Requirements
10
10
@@ -29,13 +29,13 @@ Create Pull Request so your TAs can check up your work.
29
29
30
30
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.
31
31
32
-
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.
32
+
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 code bases.
33
33
34
-
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.
34
+
Having a strong _test suite_ 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.
35
35
36
36
### Testing labs
37
37
38
-
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.
38
+
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.
39
39
40
40
### Testing with Jasmine
41
41
@@ -75,7 +75,7 @@ You should write your code on the `src/functions-and-arrays.js` file. While foll
75
75
76
76
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.
77
77
78
-
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.
78
+
When coding with tests, it is super important that you carefully read and understand the errors you are getting, this way you will know for sure what's expected from your code.
79
79
80
80
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.
Calculating a sum can be as simple as iterating over an array and adding each of the elements together.
103
103
104
-
Declare a function named `sumArray` that takes an array of numbers as an argument, 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. For now, let's practice _"declarative"_ way adding values, using loops.
104
+
Declare a function named `sumNumbers` that takes an array of numbers as an argument, and returns the sum of all of the numbers in the array. Later in the course we will learn how to do this by using the `reduce` array method, which will make your work significantly easier. For now, let's practice _"declarative"_ way adding values, using loops.
105
105
106
106
You can use the following array to test your solution:
**The goal: Learn how to refactor your code.**:muscle:
115
115
116
-
In the iteration 3, you created a function that returns the sum of an array of numbers. But what if we wanted to know how much is the sum of the length of all of the words in an array? What if we wanted to add _boolean_ values to the mix? We wouldn't be able to use the same function as above, or better saying, we would have to _tweak_ it a little bit so that it can be reused no matter what is in the array that is passed as argument when function `sumArray()` is called.
116
+
In the iteration 3, you created a function that returns the sum of an array of numbers. But what if we wanted to know how much is the sum of the length of all of the words in an array? What if we wanted to add _boolean_ values to the mix? We wouldn't be able to use the same function as above, or better saying, we would have to _tweak_ it a little bit so that it can be reused no matter what is in the array that is passed as argument when function `sumNumbers()` is called.
117
117
118
-
Here we're applying a concept we call **polymorphism**, that is, dealing with a functions' input independently of the types they're passed as.
118
+
Here we are applying a concept we call **polymorphism**, that is, dealing with a functions' input independently of the types they are passed as.
119
119
120
120
Let's create a new function `sum()` that calculates the sum for array filled with (_almost_) any type of data. Note that strings should have their length added to the total, and boolean values should be coerced into their corresponding numeric values. Check the tests for more details.
121
121
@@ -133,14 +133,14 @@ Calculating an average is an extremely common task. Let's practice it a bit.
133
133
134
134
**The logic behind this:**
135
135
136
-
1. Find the sum as we did in the first exercise (or how about reusing that the _sumArray()_?)
136
+
1. Find the sum as we did in the first exercise (or how about reusing that the _sumNumbers()_?)
137
137
2. Take that sum and divide it by the number of elements in the list.
138
138
139
139
### Level 1: Array of numbers
140
140
141
141
Declare a function named `averageNumbers` that expects an array of numbers and returns the average of the numbers:
### Bonus - Iteration #4.1: A generic `avg()` function
171
160
172
-
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're following a similar logic to the one applied on the bonus iteration 4.1 :wink:
161
+
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:
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.
171
+
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.
183
172
184
173
Do this in the form of a function `uniquifyArray` that receives an array of words as a argument.
185
174
186
-
**Starter Code**
175
+
**Starter code**
187
176
188
177
```javascript
189
178
constwords= [
@@ -207,26 +196,17 @@ Let's create a simple array search.
207
196
208
197
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.
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.
0 commit comments