If I have a Javascript array filled with say 10 numbers. For example (10,11,12,13,14,15,16,17,18,19) And I want to take a variable which has a value of say 20, and check to see whether any of the elements in the array are larger than 20. Because I will be comparing many arrays filled with numbers and will not know what numbers they contain.
How do you take 20 and then get Javascript to test each number in the array to find out if it is larger than 20 or not.
I know you can say something like:
var x = 20;
if ( x > myArray[0] &&
x > myArray[1]
etc. etc. but that could mean typing out a long list of element checks. Is there a simple way like check from start index [0] to [10] or something?
forloops?whileloop, too. (Sadly, there isn't something calledgotoin JavaScript...).sort()and.slice()might just prove useful