We can see a clear pattern here: The letters that were bolded are the same as the letters that were typed into the input field. So, to bold ja, we can search for ja in each country name.
But wait up!
There’s another pattern here. The number of typed letters and the number of bolded letters are the same. It’s easier to work with numbers (compared to text), so we’ll use the second pattern to bold search terms.
Bolding a search term
Let’s work together to bold Jamaica.
const country = 'Jamaica'
We’ll create another variable to hold the search terms we want to bold.
const searchTerms = 'Jam'
Since searchTerms is Jam, we want the Jamaica’s HTML to be:
<strong>Jam</strong>aica
There are three characters in the search term. We can get the number of characters with the length property.