This is a command from Jesus. We aren't supposed to let our hearts be full of fear or anxiety or fret. Jesus's words imply that we allow our hearts to get this way.
So, don't allow it!
When you find your heart straying into anxious thoughts or stressful feelings, stop and focus on God. Use the words in 2 Corinthians 10:5: "take every thought captive to the obedience of Christ."
Speak out loud God's word and His promises.
Don't let fear or trouble overwhelm you. It always looks worse than it is for we only see in this realm. The unseen realm is where the stuff is really happening.
Earlier in John Jesus says, "I won't leave you as orphans."
What is an orphan? A child without parents, a child left to fend for himself; a child who has no protection.
God won't leave you orphaned. He is there.
Don't struggle today. Be at peace. Keep your heart and mind centered on Jesus.