In Joshua 7:1–26, Israel was defeated by Ai in battle. As a result, Joshua and the people were demoralized such that their hearts melted and became like water (Joshua 7:5b). Having killed Achan, the Lord turned away his anger that he had directed against Israel (Joshua 7:26) and now he tells Joshua that Israel will succeed in battle. They don’t need to be afraid because of past defeat; the Lord is fighting on their behalf. God’s words would give Joshua the needed confidence to attack Ai.1
1 And the LORD said to Joshua, “Do not fear and do not be dismayed. Take all the fighting men with you, and arise, go up to Ai. See, I have given into your hand the king of Ai, and his people, his city, and his land.