unifying getInitials function in js