Suppose we have an array of strings, like this:
var arr = ['qwe', 'rty', 'uio p', 'a', 's df'];
but much longer. And a string, which is the user input.
So, on every keyup
(next character inserted in that string) I have to check if this string is present in that array.
I know I can do it by looping through the array every time - but is there any way to make it faster?
arr.indexOf(input) > -1
O(n)