In Avengers: Endgame, Captain America is able to wield Thor's hammer because he is worthy.
What I don't get is why he was able to use lightning bolts!
In Thor: Ragnarok, Odin tells Thor that Mjolnir was not the source of his powers. It was simply a tool to control his power. That means that Mjolnir doesn't create bolts of lightning, but rather helped Thor (the God of Thunder) control his powers.
So, how was Captain America able to use lightning bolts?