How to combine array of strings in all possible ways
Example 1
input
const words = ["foo", "bar"]
Output
["foobar", "barfoo"]
Example 2
input
const words = ["word","good","best"];
Output
[
  "wordgoodbest",
  "wordbestgood",
  "bestwordgood",
  "bestgoodword",
  "goodbestword",
  "goodwordbest"
]
And so on if input size increased
 
     
     
    