📜  相邻元素产品javascript代码示例

📅  最后修改于: 2022-03-11 15:03:20.888000             🧑  作者: Mango

代码示例1
function adjacentElementsProduct(items) {
    var product = 0;
    for (var i = 0; i < items.length - 1; i++) {
        product = Math.max(product, items[i] * items[i + 1]);
    }
    return product;
}

console.log(adjacentElementsProduct([3, 6, -2, -5, 7, 3]));