'Can this search bar autosuggest by any word?
The search bar only suggest results by the first letter of the first word, can i make it suggest by de contains of the result that I'm looking for, for example "Home" works just fine, but if I want to find "Home alone" and I type "alone" nothing will happen.
let suggestions = [
"Home alone",
"Home safe for sure",
"Home the one",
"Home test",
"Home good",
"Home test again",
"Home",
];
Solution 1:[1]
The filter in the codepen utilizes .startsWith to show suggestions. Try utilizing .includes which:
The includes() method returns true if a string contains a specified string.
For this specific codepen, change line 10 to:
return data.toLocaleLowerCase().includes(userData.toLocaleLowerCase());
Then try searching al to see the suggestion Home Alone
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | ydnaklementine |
