Java Check Element In Array Javascript Function Definition