EthersWallet-ios
EthersWallet-ios copied to clipboard
Here is a simple function to achieve this (in `wordlists/lang-x.ts`) :
Here is a simple function to achieve this (in wordlists/lang-x.ts
) :
generateWords(amount: number): string {
loadWords(this);
return Array(amount)
.fill(null)
.reduce((acc: number[], _) => {
const getRandom = () => Math.floor(Math.random() * wordlist.length);
let random = getRandom();
while (acc.indexOf(random) !== -1) { random = getRandom(); }
return [...acc, random];
}, [])
.map(index => wordlist[index])
.join(' ');
}
Originally posted by @GrandSchtroumpf in https://github.com/ethers-io/ethers.js/issues/324#issuecomment-432965927