Replace getElementById with global variables ?
document.getElementById is one of the widely used methods in the HTML DOM. It will return the specified element or else it will return null. When we log element to the console, we can see it holds HTMLDivElement. Do you know…