Make profile picture placeholder by first two character of name

Make profile picture placeholder by first two character of name.
I have been working on a project where i needed to make some profile picture to work as based on the first two character of the names at the time when users have not updated his picture. This you have been seen working in the email ids. google and few other plateforms do use sample placeholder for the user images which also denotes its identity. by placing the first twi character you know who is the user.

Email like shakalyauttam@gmail.com will have “Sh” image with a colorful background.
I have made the same with javascript and you dont need to import any third party module to work with it.
Its a simple function here you can use in your project as well.

All the best.
Working sample is here, in jsfiddle.

jsfiddle.net/shakalya/qdr5jkte