The joke works on the idea that normally you ask directions to a place because you don't know how to get there yourself. This is funny as it reverses that idea - A has gone up and told a complete stranger, who doesn't care where the zoo is, the directions - the complete opposite of the real situation.