Update application.js

Extracted isArray into its own function