In the last year of the war, the US hade cryptographers who work to deciphere Japanese code messages. It is important to know that Japanese code and German code wheren't the same, they were easier to decipher, because of this the U.S. was able to understand 90,000 words.
Thanks to this, the US was able to know Japanese plans and defend themselves for any Japanese attack before they could even strike.