Mountain Peaks

Mountain Peaks

A computerized geographic information system represents the profile of a mountain through a sequence of integers, where no two consecutive numbers are the same. A peak is detected as three consecutive numbers where the middle number is bigger than the other two or two consecutive numbers at left/right end of a sequence where the left/rightmost number is bigger.

example

Your program must analyze this sequence to determine whether the mountain represented has more than one peak (return true). If not enough data or just a single peak - return false.

Input: Array of integers (number).

Output: Logical value (boolean).

Examples:

assert.strictEqual(checkPeaks([2, 3, 5, 6, 7, 5, 4, 2]), false);
assert.strictEqual(checkPeaks([2, 3, 6, 5, 4, 6, 3, 2]), true);
assert.strictEqual(checkPeaks([1, 2, 3, 2, 1]), false);
assert.strictEqual(checkPeaks([1, 3, 2, 1, 2, 3, 1]), true);