title: How to check if string1 digits can be rearranged into string2?
body: <p>I want to write a function that accepts str1 and str2 and checks if str1 digits can be rearranged into str2.</p>
  <p>Currently stuck at this:</p>
  <p>My code works fine until str2 won't have any double digits.
  How can I fix this?
  <div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>function scramble(str1, str2) {
      str1 = str1.split('');
      str2 = str2.split('');
  
      let result = [];
  
      for (let i = 0; i &lt; str2.length; i++) {
          for (let j = 0; j &lt; str1.length; j++) {
              if (str2[i] === str1[j]) {
                  result.push(str1[j]);
              }
          }
      }
  
  
      for (let i = 0; i &lt; result.length; i++) {
          if (result[i] === result[i + 1]) {
              result.splice(i, 1);
              --i;
          }
      }
      return result.join('') === str2.join('')
  }
  console.log(scramble('rkqodlw','world'));
  console.log(scramble('aabbcamaomsccdd','commas')); //heres the problem</code></pre>
  </div>
  </div>
  </p>