Last active
February 24, 2017 02:26
-
-
Save Underdoge/435873ba3d683667b561c38c5a1f1fd6 to your computer and use it in GitHub Desktop.
adjacentElementsProduct
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function adjacentElementsProduct(inputArray) { | |
var i=0,x=inputArray[i]*inputArray[i+1]; | |
i++; | |
while(i+1<inputArray.length){ | |
if(inputArray[i]*inputArray[i+1]>x) | |
x=inputArray[i]*inputArray[i+1]; | |
i++; | |
} | |
return x; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment