Most people are familiar with the story of David and Goliath. When David went to face Goliath he was very confident that Goliath would be defeated, however, we must notice that he wasn’t confident in his ability to beat Goliath but rather God’s ability to do so.
1 Samuel 17:45 (NLT) David replied to the Philistine, “You come to me with sword, spear, and javelin, but I come to you in the name of the Lord of Heaven’s Armies—the God of the armies of Israel, whom you have defied. 46 Today the Lord will conquer you, and I will kill you and cut off your head. And then I will give the dead bodies of your men to the birds and wild animals, and the whole world will know that there is a God in Israel! 47 And everyone assembled here will know that the Lord rescues his people, but not with sword and spear. This is the Lord’s battle, and he will give you to us!”
Notice he said, “This is the Lord’s battle, and he will give you to us!” Where did David get that idea from, and why is he so confident? God told Joshua in Joshua 1:8 to meditate on the word day and night. Meditating here means to think about and remind oneself of it. Before and after this verse, God told Joshua three times, “…be strong and courageous!” Even back in Deuteronomy 31:6-7, Moses said “be strong and courageous!” to both Israel and Joshua. The reason they were expected to be strong and courageous was that God said he would be with them (Deut 31:6-8, Joshua 1:9) and would defeat their enemies for them (Ex 23:27, Num 10:9, Deut 6:17-19). In Deuteronomy 1:30 it says, “The Lord your God is going ahead of you. He will fight for you, just as you saw him do in Egypt.” This is the reason they were to have confidence, the Torah repeats this multiple times like in Exodus 23:27-31; 34:11 & 24, as well as Deut 11:23, 18:12; 31:3. God told them he would give them victory over all of the people living in Canaan which included the Philistines (Joshua 13:1-7). Goliath was a Philistine, so therefore God had already promised to give Israel victory over him and all of their army. This is what David was trusting in when he said what he said to Goliath. David meditated on what he heard from the Torah being read in the assembly and believed it, received, repeated it, and acted on it.