(searchtext)
| 2 | const matchList = document.getElementById("match-list"); |
| 3 | |
| 4 | const searchStates = async (searchtext) => { |
| 5 | const res = await fetch("../assets/js/StateSearchData.json"); |
| 6 | const states = await res.json(); |
| 7 | |
| 8 | console.log(states); |
| 9 | let matches = states.filter((state) => { |
| 10 | const regex = new RegExp(`^${searchtext}`, "gi"); |
| 11 | return ( |
| 12 | state.City.match(regex) || |
| 13 | state.State.match(regex) || |
| 14 | state.District.match(regex) |
| 15 | ); |
| 16 | }); |
| 17 | |
| 18 | if (searchtext.length === 0) { |
| 19 | matches = []; |
| 20 | } |
| 21 | |
| 22 | console.log(matches); |
| 23 | outputHtml(matches); |
| 24 | }; |
| 25 | |
| 26 | const outputHtml = (matches) => { |
| 27 | if (matches.length > 0) { |
no test coverage detected