occurrences(matchFct) //Object "this" is a MyArray /*Return a count (number) of the number of occurrences where matchFct returns true over our elements.*/ }
occurrences(matchFct) { let count be 0 iterate over elements (nextElem) match = matchFct(nextElem) Increment count }
occurrences(matchFct) { let count be 0 iterate over elements (nextElem) match = matchFct(nextElem) Increment count }
occurrences(matchFct) { let count be 0 iterate over elements (nextElem) match = matchFct(nextElem) if (match is true) Increment count }
occurrences(matchFct) { let count be 0 iterate over elements (nextElem) match = matchFct(nextElem) if (match is true) Increment count }
// occurrences(matchFct) var nextIndex, count nextIndex = 0 count = 0 while (nextIndex < this.size()) { var nextElem, match nextElem = this.get(nextIndex) match = matchFct(nextElem) if (match) count++ nextIndex++ } return count;