Issue
I am trying to change a const
to the preferred search engine (website linked below). Is it possible? If so, please provide a solution. Thanks!
The website: https://newtabb.gq
Website #2 (instant updates): https://newtabb.hyderite.repl.co
The code: https://replit.com/@Hyderite/newtabb (in script.js)
The code involved:
search.onclick = function() {searchQuery()};
function searchQuery() {
window.open(searchEngine + query);
}
Solution
Per the MDN Web Docs:
Constants are block-scoped, much like variables declared using the let keyword. The value of a constant can't be changed through reassignment (i.e. by using the assignment operator), and it can't be redeclared (i.e. through a variable declaration). However, if a constant is an object or array its properties or items can be updated or removed.
Per your code, the const is not an object or array so nothing about it can be changed. And if you wish to set a new value as a new variable, note you won't be able to use the same name (redeclaring it somewhere in your code).
Answered By - EssXTee
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.