Skip to content

Commit bb18ace

Browse files
authored
Merge pull request #3907 from ironhack-tech-trash-july2023/master
hints for iteration 3.2 (throw error)
2 parents 751ea3b + ee75c7b commit bb18ace

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

README.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ const numbers = [6, 12, 1, 18, 13, 16, 2, 1, 8, 10];
155155

156156
In iteration 3, you created a function that returns the sum of an array of numbers. But what if we want to calculate the sum of the length of words in an array? What if it also includes _boolean_ values? To achieve this, we must create a function allowing this flexibility.
157157

158-
You should implement the function `sum()` in this iteration. The function should take an array of mixed values - numbers, strings, and booleans. The function should add all the string lengths, numeric values, and numeric values of booleans to the total sum and return the sum. Check the tests for more details.
158+
You should implement the function `sum()` in this iteration. The function should take an array of mixed values - numbers, strings, and booleans. The function should add all the string lengths, numeric values, and numeric values of booleans to the total sum and return the sum.
159159

160160
You can use the following array to test your solution:
161161

@@ -165,6 +165,16 @@ const mixedArr = [6, 12, 'miami', 1, true, 'barca', '200', 'lisboa', 8, 10];
165165
// should return: 57
166166
```
167167

168+
169+
Note: if your function receives an array with anything different than numbers, strings or booleans (for example, if the array contains an object), you should [throw an error](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/throw). You can do that with something like this:
170+
171+
```javascript
172+
throw new Error('oops, something went wrong...');
173+
```
174+
175+
The tests expect you to throw an error with a *specific* message, check the file with the tests for more details 👀
176+
177+
168178
<br>
169179

170180
### Iteration #4: Calculate the average

0 commit comments

Comments
 (0)