Skip to content

Commit ff6a618

Browse files
committed
Refactored exercise explanation, cleaned started code
1 parent 905ce4d commit ff6a618

File tree

2 files changed

+64
-78
lines changed

2 files changed

+64
-78
lines changed

README.md

+63-69
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
![logo_ironhack_blue 7](https://user-images.githubusercontent.com/23629340/40541063-a07a0a8a-601a-11e8-91b5-2f13e4e6b441.png)
1+
<p align="center"><img src="https://user-images.githubusercontent.com/23629340/40541063-a07a0a8a-601a-11e8-91b5-2f13e4e6b441.png"/></p>
22

33
# JS | Functions & Arrays
44

@@ -13,7 +13,6 @@ In this exercise you will apply:
1313

1414
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.
1515

16-
1716
## Requirements
1817

1918
- Fork this repo
@@ -22,30 +21,34 @@ Manipulating arrays in code is a very common operation. Whether you're creating
2221
## Submission
2322

2423
Upon completion, run the following commands:
24+
2525
```
2626
$ git add .
2727
$ git commit -m "done"
2828
$ git push origin master
2929
```
30+
3031
Create Pull Request so your TAs can check up your work.
3132

32-
## Testing Introduction
33+
## Automated Testing Introduction
3334

34-
### What is testing?
35+
### What is automated testing?
3536

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.
3738

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.
3940

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.
4142

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.
4346

4447
### Testing with Jasmine
4548

46-
![Jasmine Logo](https://i.imgur.com/A1pop7h.png)
49+
<!-- ![Jasmine Logo](https://i.imgur.com/A1pop7h.png) -->
4750

48-
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.
4952

5053
We have already included Jasmine in the project you just forked, so let's see how to use it to implement our code.
5154

@@ -65,47 +68,38 @@ starter-code/
6568
└─ SpecRunner.html
6669
```
6770

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.
6972

7073
**Run tests**
7174

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:
7376

7477
![image](https://user-images.githubusercontent.com/23629340/33389609-c2f3965c-d533-11e7-9a03-e0a89314dd98.png)
7578

7679
**Pass the tests**
7780

78-
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_.
7982

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.
8184

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.
8386

8487
## Deliverables
8588

8689
Write your JavaScript in the provided `src/functions-and-arrays.js` file.
8790

88-
8991
## Iteration #1: Find the maximum
9092

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.
9294

9395
## Iteration #2: Finding Longest Word
9496

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.
9698

9799
**Starter Code**
98100

99101
```javascript
100-
const words = [
101-
'mystery',
102-
'brother',
103-
'aviator',
104-
'crocodile',
105-
'pearl',
106-
'orchard',
107-
'crackpot'
108-
];
102+
const words = ['mystery', 'brother', 'aviator', 'crocodile', 'pearl', 'orchard', 'crackpot'];
109103
```
110104

111105
## Iteration #3: Calculating a Sum
@@ -114,7 +108,7 @@ Calculating a sum is as simple as iterating over an array and adding each of the
114108

115109
<!-- 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. -->
116110

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.
118112

119113
**Starter Code**
120114

@@ -124,7 +118,7 @@ const numbers = [6, 12, 1, 18, 13, 16, 2, 1, 8, 10];
124118

125119
## Iteration #4: Calculate the Average
126120

127-
Calculating an average is an extremely common task. Let's practice it a bit.
121+
Calculating an average is an extremely common task. Let's practice it a bit.
128122

129123
**Algorithm**
130124

@@ -133,7 +127,7 @@ Calculating an average is an extremely common task. Let's practice it a bit.
133127

134128
### Level 1: Array of Numbers
135129

136-
Write a function `averageNumbers` that receives an array of numbers and calculate the average of the numbers:
130+
Declare a function named `averageNumbers` that expects an array of numbers and returns the average of the numbers:
137131

138132
**Starter Code**
139133

@@ -143,30 +137,30 @@ const numbers = [2, 6, 9, 10, 7, 4, 1, 9];
143137

144138
### Level 2: Array of Strings
145139

146-
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:
147141

148142
**Starter Code**
149143

150144
```javascript
151145
const words = [
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'
162156
];
163157
```
164158

165159
## Iteration #5: Unique Arrays
166160

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.
168162

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.
170164

171165
**Starter Code**
172166

@@ -184,16 +178,16 @@ const words = [
184178
'simple',
185179
'bring'
186180
];
187-
188181
```
189182

190183
## Iteration #6: Finding Elements
191184

192185
Let's create a simple array search.
193186

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.
195188

196189
**Starter Code**
190+
197191
```javascript
198192
const words = [
199193
'machine',
@@ -209,7 +203,7 @@ const words = [
209203

210204
## Iteration #7: Counting Repetition
211205

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.
213207

214208
**Starter Code**
215209

@@ -224,7 +218,7 @@ const words = [
224218
'eating',
225219
'matter',
226220
'truth',
227-
'disobedience'
221+
'disobedience',
228222
'matter'
229223
];
230224
```
@@ -233,31 +227,31 @@ const words = [
233227

234228
In the 20×20 grid below; What is the greatest product of four adjacent numbers in the same direction (up, down, left, right)?
235229

236-
Write a function `greatestProduct` to find the answer!
230+
Declare a function named `greatestProduct` to find the answer!
237231

238232
```javascript
239233
const matrix = [
240-
[08,02,22,97,38,15,00,40,00,75,04,05,07,78,52,12,50,77,91,08],
241-
[49,49,99,40,17,81,18,57,60,87,17,40,98,43,69,48,04,56,62,00],
242-
[81,49,31,73,55,79,14,29,93,71,40,67,53,88,30,03,49,13,36,65],
243-
[52,70,95,23,04,60,11,42,69,24,68,56,01,32,56,71,37,02,36,91],
244-
[22,31,16,71,51,67,63,89,41,92,36,54,22,40,40,28,66,33,13,80],
245-
[24,47,32,60,99,03,45,02,44,75,33,53,78,36,84,20,35,17,12,50],
246-
[32,98,81,28,64,23,67,10,26,38,40,67,59,54,70,66,18,38,64,70],
247-
[67,26,20,68,02,62,12,20,95,63,94,39,63,08,40,91,66,49,94,21],
248-
[24,55,58,05,66,73,99,26,97,17,78,78,96,83,14,88,34,89,63,72],
249-
[21,36,23,09,75,00,76,44,20,45,35,14,00,61,33,97,34,31,33,95],
250-
[78,17,53,28,22,75,31,67,15,94,03,80,04,62,16,14,09,53,56,92],
251-
[16,39,05,42,96,35,31,47,55,58,88,24,00,17,54,24,36,29,85,57],
252-
[86,56,00,48,35,71,89,07,05,44,44,37,44,60,21,58,51,54,17,58],
253-
[19,80,81,68,05,94,47,69,28,73,92,13,86,52,17,77,04,89,55,40],
254-
[04,52,08,83,97,35,99,16,07,97,57,32,16,26,26,79,33,27,98,66],
255-
[88,36,68,87,57,62,20,72,03,46,33,67,46,55,12,32,63,93,53,69],
256-
[04,42,16,73,38,25,39,11,24,94,72,18,08,46,29,32,40,62,76,36],
257-
[20,69,36,41,72,30,23,88,34,62,99,69,82,67,59,85,74,04,36,16],
258-
[20,73,35,29,78,31,90,01,74,31,49,71,48,86,81,16,23,57,05,54],
259-
[01,70,54,71,83,51,54,69,16,92,33,48,61,43,52,01,89,19,67,48],
234+
[08, 02, 22, 97, 38, 15, 00, 40, 00, 75, 04, 05, 07, 78, 52, 12, 50, 77, 91, 08],
235+
[49, 49, 99, 40, 17, 81, 18, 57, 60, 87, 17, 40, 98, 43, 69, 48, 04, 56, 62, 00],
236+
[81, 49, 31, 73, 55, 79, 14, 29, 93, 71, 40, 67, 53, 88, 30, 03, 49, 13, 36, 65],
237+
[52, 70, 95, 23, 04, 60, 11, 42, 69, 24, 68, 56, 01, 32, 56, 71, 37, 02, 36, 91],
238+
[22, 31, 16, 71, 51, 67, 63, 89, 41, 92, 36, 54, 22, 40, 40, 28, 66, 33, 13, 80],
239+
[24, 47, 32, 60, 99, 03, 45, 02, 44, 75, 33, 53, 78, 36, 84, 20, 35, 17, 12, 50],
240+
[32, 98, 81, 28, 64, 23, 67, 10, 26, 38, 40, 67, 59, 54, 70, 66, 18, 38, 64, 70],
241+
[67, 26, 20, 68, 02, 62, 12, 20, 95, 63, 94, 39, 63, 08, 40, 91, 66, 49, 94, 21],
242+
[24, 55, 58, 05, 66, 73, 99, 26, 97, 17, 78, 78, 96, 83, 14, 88, 34, 89, 63, 72],
243+
[21, 36, 23, 09, 75, 00, 76, 44, 20, 45, 35, 14, 00, 61, 33, 97, 34, 31, 33, 95],
244+
[78, 17, 53, 28, 22, 75, 31, 67, 15, 94, 03, 80, 04, 62, 16, 14, 09, 53, 56, 92],
245+
[16, 39, 05, 42, 96, 35, 31, 47, 55, 58, 88, 24, 00, 17, 54, 24, 36, 29, 85, 57],
246+
[86, 56, 00, 48, 35, 71, 89, 07, 05, 44, 44, 37, 44, 60, 21, 58, 51, 54, 17, 58],
247+
[19, 80, 81, 68, 05, 94, 47, 69, 28, 73, 92, 13, 86, 52, 17, 77, 04, 89, 55, 40],
248+
[04, 52, 08, 83, 97, 35, 99, 16, 07, 97, 57, 32, 16, 26, 26, 79, 33, 27, 98, 66],
249+
[88, 36, 68, 87, 57, 62, 20, 72, 03, 46, 33, 67, 46, 55, 12, 32, 63, 93, 53, 69],
250+
[04, 42, 16, 73, 38, 25, 39, 11, 24, 94, 72, 18, 08, 46, 29, 32, 40, 62, 76, 36],
251+
[20, 69, 36, 41, 72, 30, 23, 88, 34, 62, 99, 69, 82, 67, 59, 85, 74, 04, 36, 16],
252+
[20, 73, 35, 29, 78, 31, 90, 01, 74, 31, 49, 71, 48, 86, 81, 16, 23, 57, 05, 54],
253+
[01, 70, 54, 71, 83, 51, 54, 69, 16, 92, 33, 48, 61, 43, 52, 01, 89, 19, 67, 48]
260254
];
261255
```
262256

263-
**Happy coding!** :heart:
257+
**Happy coding!** :heart:

starter-code/src/functions-and-arrays.js

+1-9
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,7 @@
11
// Find the maximum
22

33
// Finding Longest Word
4-
const words = [
5-
'mystery',
6-
'brother',
7-
'aviator',
8-
'crocodile',
9-
'pearl',
10-
'orchard',
11-
'crackpot'
12-
];
4+
const words = ['mystery', 'brother', 'aviator', 'crocodile', 'pearl', 'orchard', 'crackpot'];
135

146
// Calculating a Sum
157

0 commit comments

Comments
 (0)