File tree Expand file tree Collapse file tree 1 file changed +5
-6
lines changed Expand file tree Collapse file tree 1 file changed +5
-6
lines changed Original file line number Diff line number Diff line change 2323 . then ( data => cities . push ( ...data ) ) ;
2424
2525function findMatches ( wordToMatch , cities ) {
26- return cities . filter ( place => {
27- // here we need to figure out if the city or state matches what was searched
28- const regex = new RegExp ( wordToMatch , 'gi' ) ;
29- return place . city . match ( regex ) || place . state . match ( regex )
30- } ) ;
26+ const regex = new RegExp ( wordToMatch , 'gi' ) ;
27+
28+ // here we need to figure out if the city or state matches what was searched
29+ return cities . filter ( place => place . city . match ( regex ) || place . state . match ( regex ) ) ;
3130}
3231
3332function numberWithCommas ( x ) {
3635
3736function displayMatches ( ) {
3837 const matchArray = findMatches ( this . value , cities ) ;
38+ const regex = new RegExp ( this . value , 'gi' ) ;
3939 const html = matchArray . map ( place => {
40- const regex = new RegExp ( this . value , 'gi' ) ;
4140 const cityName = place . city . replace ( regex , `<span class="hl">${ this . value } </span>` ) ;
4241 const stateName = place . state . replace ( regex , `<span class="hl">${ this . value } </span>` ) ;
4342 return `
You can’t perform that action at this time.
0 commit comments