First, what are you using the | symbol for? It is not the symbol you think it is.
Also, arr1[i] == NaN will always be false. You can not directly compare something with NaN to check to see if it is NaN. Do some research in how to detect if a value is NaN.