Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

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]));
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #adjacent #elements #product #javascript
ADD COMMENT
Topic
Name
7+9 =