title: adjacentElementsProduct function in ruby
body: <p>I'm stuck on an algorithm for a function called adjacentElementsProduct that accepts an array as the argument. It's supposed to return the largest product of adjacent numbers in the array. For example, if the argument is [2,4,1,3,2,6] it would return 12 because of the pair of 2 and 6. </p>
  
  <p>my code is</p>
  
  <pre><code>def adjacentElementsProduct(inputArray)
      idx1 = 0
      idx2 = 1 
  
      while idx2 &lt; inputArray.length
          pair = [inputArray[idx1], inputArray[idx1 + 1]]
          next_pair = [inputArray[idx2], inputArray[idx2 + 1]]
  
          if next_pair.reduce(:+) &gt; pair.reduce(:+)
              pair = next_pair
  
              idx1 += 1
              idx2 += 1
          else
              idx1 += 1
              idx2 += 1
  
          end
  
      end
      pair.reduce(:+)
  end
  </code></pre>
  
  <p>I just can't figure out where my code is not working. I'm just looking for a push in the right direction because I know just being given the answer won't help me as much. Can anyone help me?</p>