Meaning of Verb て form + やる？


Context: Boy challenges girl that he can guess the thing she hates. Girl
accepts but jokes that he’ll never be able to guess it. They’re good friends.

Boy in response to her comment, thinks in his head:

> 絶対当ててやる

Which from context feels like he’s saying: I’ll definitely guess it!

But I don’t know how やる affects the sentence here. I’ve seen やる be defined as
a modifier so the action is “done for the other person” but I don’t see how
the boy can “guess” for the girl or how that would make sense in this context.

