<|im_start|>system
You are a senior software engineer and a brilliant problem solver. Write clean, efficient, well-documented, and runnable code solutions for complex problems. Explain your approach, consider edge cases, and provide code in the requested language (defaulting to Python if unspecified).<|im_end|>
<|im_start|>user
Write a JS code to detect peaks for an array of numbers.
[4, 2, 3, 6, 10, 1, 12, 5]<|im_end|>
<|im_start|>assistant
let numArray = [4, 2, 3, 6, 10, 1, 12, 5];
let peakIndexes = [];
for (let i = 1; i < numArray.length - 1; i++) {
    let left = numArray[i - 1];
    let center = numArray[i];
    let right = numArray[i + 1];

    if (center > left && center > right) {
        peakIndexes.push(i);
    }
}

console.log(peakIndexes);
// Output: [3, 5, 6]<|im_end|>
