Console.log challenge change all of the links on a search results page so that they do not go anywhere? I am reading a book call Front end Web Development &quot;The big nerd ranch guide&quot;, in which I came across a silver challenge:

Go to your favorite search engine and search for &quot;anything&quot;.
Open the DevTools to the console.
With the functions you wrote in this chapter as a reference, attach event listeners to all of the links and disable their default click functionality.

Here's what I wrote:
function selectLink() {
    'use strict'
    var links = document.querySelectorAll('a');
    var linksArray = [].slice.call(links);
    return linksArray;
}

function disableClick (dis) {
    'user strict';
    dis.addEventListener('click', function (event) {
        event.preventDefault();
    });
}

function click() {
    'use strict';
    var link = selectLink();
    link.forEach(disableClick);
} 

click();

I don't know whether this is the correct method to do it, since there is no solution on the book for it.
Can I do better?
Refactoring is commonly seen as "moving out repeating code into reusable functions". But it can also easily mean "moving code that's only ever used once back to where it's being used". Although the book led you to writing individual functions, you don't have to split all this code up.

Also, if you're just turning a NodeList into an array just to use array.forEach(), then this conversion is unnecessary. NodeList already comes with a forEach method (unless you still care about IE).

Your code could be as short as:

document.querySelectorAll('a').forEach(link =&gt; {
  link.addEventListener('click', event =&gt; event.preventDefault())
})