Created
February 5, 2014 15:49
-
-
Save slopeofhope81/8826558 to your computer and use it in GitHub Desktop.
Write a function countZeroes, which takes an array of numbers as its argument and returns the amount of zeroes that occur in it. Use reduce
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Make the function abstract using reduce. | |
| function countZeroes(numbers){ | |
| function count(total,num){ | |
| return total+(num ===0?1:0); <<===this is ternary equation!!! | |
| } | |
| return reduce(count, 0, numbers) | |
| }; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment