From dff1d9a4d18c3da0d0d619aee732556c5d4ac467 Mon Sep 17 00:00:00 2001 From: Carlos <54871261+okaabe@users.noreply.github.com> Date: Tue, 10 Nov 2020 23:47:35 -0300 Subject: [PATCH] Removed and added variables Removed useless variables and added a variable... Added const/let to variable declaration... --- scr/search.js | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/scr/search.js b/scr/search.js index 7727e68..6861ba9 100644 --- a/scr/search.js +++ b/scr/search.js @@ -3,15 +3,17 @@ window.onload = function() { } function initSearchBar() { - document.getElementById("search-bar-input").value = "" - document.getElementById("search-bar-input").focus() + const searchBarInput = document.getElementById("search-bar-input") + + searchBarInput.value = "" + searchBarInput.focus() - document.getElementById("search-bar-input").addEventListener("keypress", (event) => { - if (event.key != 'Enter') return + searchBarInput.addEventListener("keypress", (event) => { + if (event.key !== 'Enter') return - googleSearchUrl = "https://www.duckduckgo.com/?q=" - otherThing = "&atb=v225-7&ia=web" - query = document.getElementById("search-bar-input").value.replace(/\ /g, "+") - document.location = googleSearchUrl + query + otherThing + const searchEnginer = "https://www.duckduckgo.com/?q=" + const endQuery = "&atb=v225-7&ia=web" + + document.location = searchEnginer + searchBarInput.value.replace(/\ /g, "+") + endQuery }) }