Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

adjacent elements product javascript

function solution(inputArray) {
    let max = inputArray[0] * inputArray[1];
    for (let i = 1; i < inputArray.length - 1; i++) {
        let product = inputArray[i] * inputArray[i + 1];
        if (product > max) {
            max = product;
        }
    }
    return max;
}
 
PREVIOUS NEXT
Tagged: #adjacent #elements #product #javascript
ADD COMMENT
Topic
Name
4+5 =