Created
October 16, 2019 20:21
-
-
Save jerolan/107a6e2192e669f8f669d273b97d6805 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 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