Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

adjacent elements product javascript

function adjacentElementsProduct(arr) {
  return Math.max(...arr.slice(0, -1).map((n, i) => n * arr[i + 1]))
}


console.log(adjacentElementsProduct([3, 6, -2, -5, 7, 3]));
 Run code snippet
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #adjacent #elements #product #javascript
ADD COMMENT
Topic
Name
1+9 =