JavaScript doesn't provide a way to do that for you, you have to do it yourself.
I want to check if number is less then any all values in arr...
It would be either "any value in arr
" or "all values in arr
". "any all values in arr
" doesn't make sense.
If you mean "number
is less than all values in arr
", probably the easiest way is the every
function on arrays:
if (arr.every(e => number < e)) {
If you mean "number
is less than any value in arr
", you want some
instead:
if (arr.some(e => number < e)) {
One good thing about that is they short-circuit: As soon as every
/some
knows the result, it stops looping. For every
, that means the first time the callback returns a falsy value; for some
, that means the first time the callback returns a truthy value.