I am using this pattern to create list of live suggestions. ( https://www.w3schools.com/howto/howto_js_autocomplete.asp ). Do you have any idea how can I limit suggested items to 5? I dont wanna see list of 100 items displayed because they match search.
Asked
Active
Viewed 57 times
1 Answers
0
You can take the first 5 items out of the matches array and show that instead of all matches with the Array.prototype.slice
method.
var countries = ["Afghanistan","Albania","Algeria","Andorra","Angola","Anguilla","Antigua & Barbuda","Argentina","Armenia","Aruba"];
var firstFiveCountries = countries.slice(0, 5);
console.log(firstFiveCountries);

Emiel Zuurbier
- 19,095
- 3
- 17
- 32
-
Yes, but where exactly should I put it? – 9.krolik Feb 05 '20 at 22:17
-
Can't tell without you sharing your code. Show me what you've done and I'll try to help out. Add the JavaScript to your original question. – Emiel Zuurbier Feb 05 '20 at 22:19