-3

I try to create a function that gives me a true or false.

function libs(selector){
    let elementAll;
    if(typeof selector !== 'object'){
        elementAll = document.querySelectorAll(selector);
    }
    return{
        windowScroll: (props) => {
            window.onscroll = function (e) {  
            //return true
            }
        }
    }
}

I call the function in my footer

if(libs().windowScroll()){
//if is true do something
};

The code above do not give me the boolean

Who can help me with this?

Ruudje
  • 1
  • 3
  • `doscrollTop` method doesn't return anything. Notice, that the only return statement inside the method is in an event handler, its return value is ignored, because the handler is called from the event queue. – Teemu Sep 02 '23 at 08:07
  • @Teemu among other problems, like `let window` or using `pixels` which might or might not be defined at that point. – VLAZ Sep 02 '23 at 08:09
  • ... and using `selector` argument, which was never passed. – Teemu Sep 02 '23 at 08:11
  • I cleared my question – Ruudje Sep 02 '23 at 11:36
  • 1
    windowScroll does one thing. It assigns an event handler to window.onscroll that will run **at some future time**. Then it finished. Then it returns undefined because it has no return statement. – Quentin Sep 02 '23 at 11:44

0 Answers0