Skip to content

Instantly share code, notes, and snippets.

@jerolan
Created October 16, 2019 20:21
Show Gist options
  • Save jerolan/107a6e2192e669f8f669d273b97d6805 to your computer and use it in GitHub Desktop.
Save jerolan/107a6e2192e669f8f669d273b97d6805 to your computer and use it in GitHub Desktop.
function largestPair(num) {
let pair = null;
num
.toString()
.split("")
.forEach((val, index, arr) => {
if (arr.length - 1 !== index) {
let currentPair = parseInt(val + arr[index + 1]);
if (pair < currentPair) pair = currentPair;
}
});
return pair;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment