I am in the process of developing a function that will create a unique serial id by replacing a string with the format; xxxx-xxxx-xxxx-xxxx. The desired outcome is a serial like this: ABCD-1234-EFGH-5678, where the first and third parts consist of letters and the second and last parts are numbers. Below is my current code:
public generateUniqSerial() {
return 'xxxx-xxxx-xxx-xxxx'.replace(/[x]/g, function (c) {
let r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8)
return v.toString(16)
})
}
The above code gives a result similar to this: "7f8f-0d9a-fd5-450f". How can I modify this function to achieve the desired output in the format: ABCD-1234-EFGH-6789?