function randomly doesn't work

the program is meant to remove the first number from the array and check if what the second is and display the image that is linked. the code randomly stops working on the button press then after couple press it starts working again