Answer:
x=arr[arr.length-2]; is the correct answer for the given question.
Explanation:
In the above statement firstly we calculate the length of the given array.The arr.length function is used to calculate the array length.As mention in the question we have to assign the next to last element of the array to the variable x, so we used arr[arr.length-2] and finally, we assign them to the variable x.
so the final statement is x=arr[arr.length-2];