Skip to content

Instantly share code, notes, and snippets.

@H2CO3
Created September 16, 2018 07:04
Show Gist options
  • Save H2CO3/3a8a83a0339f5e35bd2b8e8fc343b1b8 to your computer and use it in GitHub Desktop.
Save H2CO3/3a8a83a0339f5e35bd2b8e8fc343b1b8 to your computer and use it in GitHub Desktop.
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