1

I have an array of values that are produced from an equation.

e.g.

testArray = [1,2,3,4,5,6,7,8,9,10];

What I want to do is write a function to look for all the values over a particular value and output the result.

So for example, in the above testArray how would I return all the values over 7 (8,9, 10 only not including 7)?

Happy for the response to use Javascript and/or Jquery.

Thanks in advance.

1 Answer 1

2

You could use filter().

var testArray = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10].filter(function(element) {
    return element > 7;
});

jsFiddle.

Sign up to request clarification or add additional context in comments.

1 Comment

Aha! I knew i was missing something obvious. This is perfect thankyou :D

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.