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...
 
function scramble(str1, str2) {
 let letterHolder = {};
 for (let letter of str1) {
   if(letterHolder[letter]) letterHolder[letter]++;
   else letterHolder[letter] = 1;
 }
 for (let letter of str2) {
   if(!letterHolder[letter]) return false
   else letterHolder[letter]--;
 }
 return true;
}
code of conduct - report abuse