Here is what I have managed to achieve so far:
mounted() {
const randomVariants = [...Array(3)].map(() =>
this.baseWord
.split('')
.sort(() => 0.5 - Math.random())
.join('')
)
const variantsWithoutInitialWord = randomVariants.filter(
(word) => word !== this.baseWord // Removing if baseWord is present
)
this.result = [...new Set(variantsWithoutInitialWord)] // Removing duplicates
},
I want to generate multiple variations from a single string value, for example: given "orange", the generated values will be:
- "ornage"
- "oregn"
- "ograne"
The first two characters and last one will remain the same. Only the other characters will be shuffled randomly. Additionally, I also need the original value with some static characters like "xy.........z" where only x
, y
, and z
are fixed while the inner characters will be randomized.