How Much is True?

Published by Matt in

Create a function which returns the number of true values there are in an array.

Examples

count_true([true, false, false, true, false]) ➞ 2

count_true([false, false, false, false]) ➞ 0

count_true([]) ➞ 0

Notes

  • Return 0 if given an empty array.
  • All array items are of the type bool (true or false).
Watch a quick demo on how Edabit works.