Hello. I’m doing the project in clean Javascript. But I can’t find how to add autocomplete to it. I googled but it seems everybody does the project in jQuery, so I can’t find the right code for me. Can anybody help me?

Coding your own autocomplete is a tall order, which is why everyone uses jQuery or some other library. You’ll have to do a few things:

Get the user input as it’s being typed (bind a listener to the keyup event)

Make the required network call on the input

Format the results and output them as a dropdown box

Make sure each result is clickable and will properly fill in the selected text, then perform a search

I always find (3) to be really difficult, but I kinda suck at positioning elements. The real challenge is in fixing the small details. For instance, you don’t want to send a network request every time the user types something because you could end up sending a lot of unnecessary data. So, you’d need to debounce the input so it only searches after 250ms of inactivity, or something like that. You also don’t want to send requests for inputs that are too small (who really needs to autocomplete “dog”, anyways?), so you’ll want to filter out any input that is smaller than some threshold - 3 letters is a typical cut off, from what I’ve seen. Keep in mind that you can tailor your Wikimedia query to only receive the titles of articles which would make for a much more efficient request.