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.

Revisions

  1. jerolan created this gist Oct 16, 2019.
    15 changes: 15 additions & 0 deletions largestPair.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,15 @@
    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;
    }