DEV Community

Discussion on: Daily Challenge #306 - Largest Possible Product

Collapse
 
grglldz profile image
Guiorgui • Edited
function adjacentProduct(a) {
    const result = [];
    for(let i = 0, len = a.length - 1; i < len; i++) {
        result.push(a[i] * a[i+1]);
    }
    return Math.max(...result);
}
Enter fullscreen mode Exit fullscreen mode