// another attempt. keep timing out
function scramble(str1, str2) {
var arr=[],strk;
for(var i=0,len=str1.length;i<len;i=i+25){
strk=str1.slice(i,i+25);
arr.push(strk);
}
var spl2=str2.split(''),
matches;
return spl2.every(function(el,index,_arr){
for(var j=0,k=arr.length;j<k;j++){
matches=arr[j].indexOf(el);
if(matches!==-1){
arr[j]=arr[j].slice(0,matches)+arr[j].slice(matches+1);
return true;
}
}
return false;
});
}
function scramble(str1, str2) {
var spl1=str1.split('').sort().join(''),
spl2=str2.split('').sort(),
matches;
return spl2.every(function(el,index,arr){
matches=str1.indexOf(el)!==-1;
if(matches){
str1=str1.replace(el,'');
return true;
}
return false;
});
}
// this is obviously better, though it still fails, and it doesn't do anything different for large strings