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
# Configuration for probot-stale - https://github.com/probot/stale
2
+
3
+
# Number of days of inactivity before an Issue or Pull Request becomes stale
4
+
daysUntilStale: 30
5
+
6
+
# Issues or Pull Requests with these labels will never be considered stale. Set to `[]` to disable
7
+
exemptLabels: []
8
+
9
+
# Only issues or pull requests with all of these labels are check if stale. Defaults to `[]` (disabled)
10
+
# onlyLabels:
11
+
# - TestLabel
12
+
13
+
# Number of days of inactivity before an Issue or Pull Request with the stale label is closed.
14
+
# Set to false to disable. If disabled, issues still need to be closed manually, but will remain marked as stale.
15
+
daysUntilClose: 2
16
+
17
+
# Label to use when marking as stale
18
+
staleLabel: stale
19
+
20
+
# Comment to post when marking as stale. Set to `false` to disable
21
+
markComment: >
22
+
This pull request has been automatically marked as stale because it didn't have any recent activity. It will be closed if no further activity occurs. Thank you
Copy file name to clipboardExpand all lines: README.md
+47-18Lines changed: 47 additions & 18 deletions
Original file line number
Diff line number
Diff line change
@@ -57,26 +57,28 @@ starter-code/
57
57
├── src
58
58
│ └── functions-and-arrays.js
59
59
├── tests
60
-
│ └── FunctionsAndArraysSpec.js
60
+
│ └── functions-and-arrays.spec.js
61
61
└─ SpecRunner.html
62
62
```
63
63
64
64
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.
65
65
66
-
**Run tests**
66
+
#### Run tests
67
67
68
68
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 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_.
74
+
You should write your code 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.
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
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.
79
79
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.
81
+
80
82
## Deliverables
81
83
82
84
Write your JavaScript in the provided `src/functions-and-arrays.js` file.
Calculating a sum is as simple as iterating over an array and adding each of the elements together.
102
+
Calculating a sum can be as simple as iterating over an array and adding each of the elements together.
101
103
102
-
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. For now, let's practice _"manual"_ way using loops.
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.
103
105
104
106
You can use the following array to test your solution:
### Bonus - Iteration #3.1: A generic `sum()` function
111
113
112
114
**The goal: Learn how to refactor your code.**:muscle:
113
-
In the iteration 3, you created a function that will return a sum of array of numbers. But what if we want to know how much is a sum of some array of words? 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 it can be reused no matter what is in the array that is passed as argument when function _sumArray()_ is called.
114
115
115
-
Let's create a new function `sum()` that calculates the sum for array filled with (_almost_) any type of data. Check the tests for more details.
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.
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.
119
+
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.
116
121
117
122
You can use the following array to test your solution:
### Bonus - Iteration #4.1: A generic `avg()` function
155
171
156
-
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.
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:
## Bonus - Iteration #8: Product of adjacent numbers
223
248
224
-
What is the greatest product of four adjacent numbers? We consider adjacent any four numbers that are next to each other in horizontal, vertical o diagonal.
249
+
What is the greatest product of four adjacent numbers? We consider adjacent any four numbers that are next to each other horizontally or vertically.
225
250
226
251
For example, if we have a 5x5 Matrix like:
227
252
@@ -235,7 +260,7 @@ For example, if we have a 5x5 Matrix like:
235
260
236
261
The greatest product will be the `20`x`20`x`20`x`4` = `32000`;
237
262
238
-
Declare a function named `greatestProduct` to find it in the 20×20 grid below!
263
+
Declare a function named `greatestProduct(matrix)` to find it in the 20×20 grid below!
239
264
240
265
```javascript
241
266
constmatrix= [
@@ -262,4 +287,8 @@ const matrix = [
262
287
];
263
288
```
264
289
290
+
## Bonus - Iteration #8.1: Product of diagonals
291
+
292
+
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.
0 commit comments