Hi, nice little example :) Instead of the forEach loop you could use a map function, so that you don't need the results closure.
const showList = () => { results.innerHTML = ""; const newElements = data .filter((item) => { return ( item.country.toLowerCase().includes(search_term) || item.name.toLowerCase().includes(search_term) ); }) .map((e) => { const li = document.createElement("li"); li.innerHTML = `<i>Name:</i> ${e.name} || <i>Country:</i> ${e.country}`; return li; }); results.append(...newElements); };
Ah your right, missed that part, thanks for the addition! 💜
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Hi, nice little example :)
Instead of the forEach loop you could use a map function, so that you don't need the results closure.
Ah your right, missed that part, thanks for the addition! 💜