re: Daily Coding Puzzles - Nov 4th - Nov 9th VIEW POST

TOP OF THREAD FULL DISCUSSION
re: Thursday Scramblies (5 KYU): Complete the function scramble(str1, str2) that returns true if a portion of str1 characters can be rearranged to m...
 

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;
}
code of conduct - report abuse