DEV Community

loading...

Discussion on: Daily Coding Puzzles - Nov 4th - Nov 9th

Collapse
thesoreon profile image
Paul Susicky

Not a fancy solution, but it seems to work 😃

function scramble(s1, s2) {
    if (s1.length < s2.length) return false;

    const _s2 = s2.split("");

    s1.split("").forEach(val => {
        if (_s2.includes(val)) _s2.splice(_s2.indexOf(val), 1);
    });

    return _s2.length == 0;
}