I'd like to be able to take a variable that is a set of numbers in string form, for example call it str, and insert a random number between 1 and 10 every other space in that string. Right now I have this code:
str.toString().match(/.{1}/g).join((Math.floor((Math.random() * 10)
+ 1)).toString())
This almost does it, however it will generate one random number and insert that every time instead of generating new random numbers for every other space. For example, if str = '1234567890', I'd like it to turn into something like 18293547596173889302 but instead I get something like 182838485868789808. Any help would be appreciated, thanks!
Aucun commentaire:
Enregistrer un commentaire