Finding middle value

Its a logic to find out the middle element in an array

The middle element is 7,11


// Question : Given Values for X,Y and an array A of size N, Print the values that are in between X and Y.
//solution:
let arr = [4, 3, 7, 11, 50, 1];
let x = 4;
let y = 20;

if (x < y) {
    let i = 0;//1,2,3
    while (i < arr.length) {
        if (arr[i] > x && arr[i] < y) {
            console.log(arr[i]);
        }
        i++;
    }
} else {
    console.log("condition mismatch");
}