logo CodeStepByStep logo

countInRange

Language/Type: JavaScript arrays
Author: Eric Roberts (added by Melissa Hovik on 2017/08/14)

Write a function named countInRange that accepts three parameters: an array of integers, a minimum and maximum integer, and returns the number of elements in the array within that range inclusive. For example, if the array v contains [28, 1, 17, 4, 41, 9, 59, 8, 31, 30, 25], the call of countInRange(v, 10, 30) should return 4.

You may assume that the array passed is non-null and contains only integers. If the array is empty, return 0. Do not modify the array that is passed in.

Function: Write a JavaScript function as described, not a complete program.

You must log in before you can solve this problem.

Log In

Need help?

Stuck on an exercise? Contact your TA or instructor.

If something seems wrong with our site, please

Is there a problem? Contact us.