Skip to content

Instantly share code, notes, and snippets.

@proustibat
Last active December 11, 2017 18:02
Show Gist options
  • Save proustibat/d93c529685b31a5f7a19e6d54649c71a to your computer and use it in GitHub Desktop.
Save proustibat/d93c529685b31a5f7a19e6d54649c71a to your computer and use it in GitHub Desktop.
Given an array of integers, find the pair of adjacent elements that has the largest product and return that product.
const adjacentElementsProduct = arr => Math.max( ...arr.slice( 1 ).map( ( n, i ) => n * arr[ i ] ) );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment