Skip to content

Latest commit

 

History

History
20 lines (14 loc) · 556 Bytes

(8 kyu) Counting sheep.md

File metadata and controls

20 lines (14 loc) · 556 Bytes

Counting sheep... (8 kyu)

https://www.codewars.com/kata/counting-sheep-dot-dot-dot

Consider an array of sheep where some sheep may be missing from their place. We need a function that counts the number of sheep present in the array (true means present).

For example,

[true,  true,  true,  false,
  true,  true,  true,  true ,
  true,  false, true,  false,
  true,  false, false, true ,
  true,  true,  true,  true ,
  false, false, true,  true]

The correct answer would be 17.

Hint: Don't forget to check for bad values like null/undefined