I have validRange(x,y,z) function, it gets an array and 2 numbers, If array's numbers located in this 2 number's range then it returns true, If the array contains a number that is not in the range, the function returns false. For example` validRange([11,1,15,13,14], 10, 20); this will return false, cause 1 is not in range,
validRange([11,15,13,14], 10, 20) and this will return true.
What I have tried:
I have tried like this, but why is it not working?
function validRange(x, y, z) {
for(var i = 0; i < x.length; i++){
if(x[i] > y && x[i] < z){
return true;
}
else{
return false;
}
}
}
console.log(validRange([11,1,15,13,14], 10, 20));