JSFiddle - React, Tailwind, and code Playground

by roskoshinsky

JavaScript

const task10 = (s1, s2, operations) => {
    const [aShort, aLong] = [s1, s2].sort( (a, b) => a.length - b.length).map(v => v.split("").sort());
    const aDiff = aLong.filter(v => !aShort.includes(v)).concat(aShort.filter(v => !aLong.includes(v)));
    if (aDiff.length > operations) {
    	return false;
    }
    return true;
}

console.log(task10("cat", "ca", 2));