i've searched a lot but havent found exactly what i am trying to do. But here goes:
I want to input a sentence / string in javascript and output all randomized variations of that sentence.
Example input: 'my test sentence 123' output: 'test my sentence 123', 'my sentence 123 test', '123 sentence my test', and so on, and stop when theres no variations left.
I've split the sentence into words in an array, but im a bit stuck on how to proceed to randomize the words and join them to new sentences in a list or new array.
code so far:
let str = "my test sentence 123";
let words = str.split(" ");
for (let i = 0; i < words.length - 1; i++) {
words[i] += " ";
}
A bit stuck on how to proceed. My thought process is: I have the words variable / array, but i need to randomize each word, output new strings but also check the existing ones so i don't duplicate any of them.
Thanks for all help i can get to learn more :)