re: Daily Challenge #18 - Triple Trouble VIEW POST

FULL DISCUSSION
 

A day late to the party, but here's my solution:

const makeRun = (v, {ofLength = 1} = {}) => Array.from({length: ofLength}, () => v).join("");

const hasTripleTrouble = (triple, double) => {
    const [tripleStr, doubleStr] = [triple, double].map(v => String(v));
    return (Array.from({length: 10}, (_, idx) => idx)
                 .some(digit => (tripleStr.indexOf(makeRun(digit, {ofLength: 3})) > -1
                              && doubleStr.indexOf(makeRun(digit, {ofLength: 2})) > -1)));
}

Gist: gist.github.com/kerrishotts/85214d...

code of conduct - report abuse