# How to get total count of passed in subject based on marks?

I have array of marks for one student like below
var marks = [15,38,35,25,19,28];

Now I want to get the total count of passed in subject in which marks above minimum passing marks (28)
For e.g. 38+35+28 >=28 = 3

Need solution in javascript or jQuery.
Rgonzo1971

HI,

pls try
``````var count = 0;
for(var i = 0; i < marks .length; ++i){
if(marks [i] >= 28)
count++;
}
``````
Regards
@Sunilgohel, you can use foreach loop of jQuery for simpler solution!

Please find below code like (not tested, but may works for you!)
``````//Call function to get total count of passed subject
var totalMarsk = marks.reduce(getCountOfArray);

//Function to manipulate passes subject and count
function getCountOfArray(total, num) {
}
``````

Hope you get idea from this!
SOLUTION
Rgonzo1971

membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
well what you'll need to do is use a for loop to iterate over each mark then check if it's over 28, if it is leave it, if not drop it from your array.  there's a pop function that will do that for you, once you've done this the length property will give you the number of subjects your student passed.

@everyone, this is homework, be a professional maybe instead of providing the answer give the student some advice and let him or her learn something.