Admiral chester nimitz learn of the japanese plans at the battle of midway from the intercepted messages. also, is is because the united states, they had broken the japanese naval code and they were able to read a significant part of the messages to give him a good idea of japanese intentions.