Created
September 16, 2018 07:04
-
-
Save H2CO3/3a8a83a0339f5e35bd2b8e8fc343b1b8 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 getLargestArray(a, b) { | |
let as = a.map(_ => 'x').join(''); | |
let bs = b.map(_ => 'x').join(''); | |
let arx = new RegExp(as); | |
let brx = new RegExp(bs); | |
let aNotShorter = as.match(brx) !== null; | |
let bNotShorter = bs.match(arx) !== null; | |
let compare = aNotShorter - bNotShorter; | |
switch (compare) { | |
case -1: return b; | |
case 1: return a; | |
default: return null; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment