I would like to convert this Python code into JavaScript using Node.JS so I can use it in my application. How may I do this in Node.JS JavaScript.
Current Python code:
import random
import string
chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'
ERC = []
for i in list(range(15)):
ERC[i] = '-'.join(''.join(random.choice(chars) for i in range(5)) for i in range(4))
The above code gets random characters from the variable which acts as a whitelist of alphanumeric characters I want to use, the format is 4 segments of 5 random characters separated by a dash. I have looked and found random-js but I haven't found it very concluding for my needs. I need something like node-randomstring, but that the alphabetical characters are in upper case. Math.random() doesn't work for me because it returns numbers between 0 and 1.
An example of the final output (from my code) looks like SY51R-APE9S-WM8ZC-L3ZP2