Peak Element In Array Using Javascript Variables