And YHWH said to Joshua, “See, I have given Jericho into your hand, with its king and mighty men of valor..."
Joshua 6:2

Joshua could see that Jericho had already fallen by the way they had locked themselves inside their city. If you don't lose your cool, a terrified enemy will often defeat himself.