Skip to content

Instantly share code, notes, and snippets.

@RahmatSaeedi
Last active May 10, 2021 14:20
Show Gist options
  • Save RahmatSaeedi/67df1b0ccf057e04008e70a0bc5e23f7 to your computer and use it in GitHub Desktop.
Save RahmatSaeedi/67df1b0ccf057e04008e70a0bc5e23f7 to your computer and use it in GitHub Desktop.
CodeSignal - Arcade - Intro - JS - adjacentElementsProduct
function adjacentElementsProduct(inputArray) {
let product = inputArray[0]*inputArray[1];
if(inputArray.length === 2) {
return product;
} else {
for(let i = 1; i < inputArray.length - 1; i++) {
product=Math.max(product, inputArray[i] * inputArray[i+1]);
}
return product;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment