Help in JS code

Hi I’m new to this, need help with some JS code

I found this code to generate a UK driving Licence number by adding a first name, last name and date of birth.
There is an issue in the outcome, instead of getting initials of the first name and middle name, it gets two letters from the first name.
And if there is no middle name then it should be replaced with the number 9

I have added a picture for illustration purposes

Hope that makes sense

Link to the repository
https://github.com/ElectricWizard1988/licence-gen

Thanks