How Much is True?
Challenge Difficulty: Easy | Estimated completion time: ~5 minutes
Create a function which returns the number of true values there are in an array.
Examples
countTrue([true, false, false, true, false]) ➞ 2
countTrue([false, false, false, false]) ➞ 0
countTrue([]) ➞ 0Notes
- Return
0if given an empty array. - All array items are of the type bool (
trueorfalse).
Solution
Python
Output