title: Find all permutations of 2 arrays in JS
body: <p>I'm trying to find every permutations of 2 arrays like this:</p>
  
  <pre><code>// input
  lowerWords = ['one', 'two', 'three' ] 
  upperWords = [ 'ONE', 'TWO', 'THREE' ]
  
  // output
  keywords = {
    'one two three': true,
    'ONE two three': true,
    'ONE TWO three': true,
    'ONE TWO THREE': true,
    'ONE two THREE': true,
    'one TWO three': true,
    'one two THREE': true,
    'one TWO THREE': true,
  }
  </code></pre>
  
  <p>It should function with more than 3 items, both arrays will always be same length. This is my code:</p>
  
  <pre><code>const keywords = {}
  const lowerWords = ['one', 'two', 'three' ] 
  const upperWords = [ 'ONE', 'TWO', 'THREE' ]
  const wordCount = lowerWords.length
  
  let currentWord = 0
  let currentWords = [...upperWords]
  while (currentWord &lt; wordCount) {
    currentWords[currentWord] = lowerWords[currentWord]
    let keyword = currentWords.join(' ')
    keywords[keyword] = true
    currentWord++
  }
  
  currentWord = 0
  currentWords = [...lowerWords]
  while (currentWord &lt; wordCount) {
    currentWords[currentWord] = upperWords[currentWord]
    let keyword = currentWords.join(' ')
    keywords[keyword] = true
    currentWord++
  }
  </code></pre>
  
  <p>result is missing some</p>
  
  <pre><code>ONE TWO THREE: true
  ONE TWO three: true
  ONE two three: true
  one TWO THREE: true
  one two THREE: true
  one two three: true
  </code></pre>