Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const getGets = (arr) => {
- let index = 0;
- return () => {
- const toReturn = arr[index];
- index += 1;
- return toReturn;
- };
- };
- // this is the test
- const test = [
- '6',
- '-26 -25 -28 31 2 27'
- ];
- const gets = this.gets || getGets(test);
- const print = this.print || console.log;
- let n = +gets();
- let arr = gets();
- let len = 0
- let i;
- let indexResult = -1;
- function firstLarger(arr){
- len = arr.length;
- for( i = 1; i < len - 1; i += 1){
- if(arr[i] > arr[i - 1] && arr[i] > arr[i + 1]){
- indexResult += i + 1;
- break;
- }
- }
- return console.log(indexResult);
- }
- firstLarger(arr);
Add Comment
Please, Sign In to add comment