God gave Joshua the plan to defeat Ai. He was to sneak some of his men behind the city of Ai to prepare for an ambush. Joshua and some others would lure the men of Ai to pursue after them, leaving their city unprotected. When the men were gone from their city the ambushers were to set the city on fire. The people of Ai would turn to save their city and be met by the ambushers or turn again to be met by the people with Joshua. Either way the people of Ai would be trapped by the Israelites. Victory was in the hands of Joshua. All he needed to do was to follow the strategy The Lord had given him.
God could lay out this plan for victory and guarantee a win because He was already there. He knew each move the people of Ai would make. Because of this He was able to come up with the perfect plan to counteract them.
The same is true with your life. God already knows your entire story. He knows each situation you’ll face. And since He has seen what you’ll come up against He knows how to lead you through victoriously. You just need to follow His strategy.