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
### Bonus - Iteration #3.1: Calculate the sum for array filled with (_almost_) any type of data
110
+
### Bonus - Iteration #3.1: A generic `sum()` function
111
111
112
-
**The goal: Learn how to refactor your**
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.
112
+
**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
+
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.
114
116
115
117
You can use the following array to test your solution:
### Bonus - Iteration #4.1: A generic `avg()` function
153
155
154
-
Create function `avg(arr)` that receive any array filled with numbers and/or strings and calculates average.
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.
0 commit comments