Answers for "adjacent elements product javascript"

0

adjacent elements product javascript

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]));
Posted by: Guest on October-22-2020

Code answers related to "adjacent elements product javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language