Check out example codes for "Given an array of integers, find the pair of adjacent elements that has the largest product and return that product.". It will help you in understanding the concepts better.

Code Example 1

function adjacentElementsProduct(inputArray) {
    var cb = Number.NEGATIVE_INFINITY;
    for(var i=0;i<inputArray.length-1;i++){
        if(inputArray[i]*inputArray[i+1] > cb){
          cb = inputArray[i]*inputArray[i+1];
  return cb;

Learn ReactJs, React Native from