Practice
JavaScriptData StructuresReactConcepts
Sign in
← Back to problems

Count Above Threshold

Working With Arraysmedium

Course · Section 11: Working With Arrays · Lecture 156: Data Transformations: map, filter, reduce

Implement `countWhere(nums, threshold)` returning how many numbers are strictly greater than `threshold`.

Sample tests

Input: countWhere([1,5,3,8], 4)
Output: 2
Input: countWhere([1,2], 5)
Output: 0

+ 1 hidden test run on Submit.

Hints

Common pitfalls
  • Using >= when strictly greater is required.

Learning resources

  • MDN: Array iteration methods
Approach & explanation (try first)

filter on n > threshold then length counts the qualifying values.

Loading...
⌘/Ctrl + Enter

Run your code to see results.