adjacent elements product javascript

Solutions on MaxInterview for adjacent elements product javascript by the best coders in the world

showing results for - "adjacent elements product javascript"
Monica
20 Apr 2016
1function adjacentElementsProduct(items) {
2    var product = 0;
3    for (var i = 0; i < items.length - 1; i++) {
4        product = Math.max(product, items[i] * items[i + 1]);
5    }
6    return product;
7}
8
9console.log(adjacentElementsProduct([3, 6, -2, -5, 7, 3]));