(array, property, value, startIndex, endIndex)
| 21 | * @return {number} The total number of elements with properties matching the given value. |
| 22 | */ |
| 23 | var CountAllMatching = function (array, property, value, startIndex, endIndex) |
| 24 | { |
| 25 | if (startIndex === undefined) { startIndex = 0; } |
| 26 | if (endIndex === undefined) { endIndex = array.length; } |
| 27 | |
| 28 | var total = 0; |
| 29 | |
| 30 | if (SafeRange(array, startIndex, endIndex)) |
| 31 | { |
| 32 | for (var i = startIndex; i < endIndex; i++) |
| 33 | { |
| 34 | var child = array[i]; |
| 35 | |
| 36 | if (child[property] === value) |
| 37 | { |
| 38 | total++; |
| 39 | } |
| 40 | } |
| 41 | } |
| 42 | |
| 43 | return total; |
| 44 | }; |
| 45 | |
| 46 | module.exports = CountAllMatching; |
no test coverage detected
searching dependent graphs…