How to write a time-increasing polling method without using global variables

A question I encountered in the interview today has not been figured out for a long time and has been despised.
requires that the
1 and poll methods receive two functions, checkStatus and callback, where the return value of checkStatus is of Boolean type, and true or false,callback is a callback function.
2. If checkStatus returns true, to execute callback, otherwise continue to execute checkStatus, but there will be a delay.
3. Polling time needs to increase constantly. After the first execution of checkStatus returns false, 1000ms is required to execute it for the second time, and the time of each subsequent execution will be increased by 1.5 times.
4, must not use global variables .

function time1(){
    var t = 1000;
    function time2(){
        t *= 1.5;
           return t;
    }
    return time2;
}
var time3 = time1();
function poll(checkStatus,callback){
    if(checkStatus()){
        callback();
    }else{
        setTimeout(function(){
            console.log(new Date());
            poll(checkStatus,callback);
        },time3());
    }
}
function checkStatus(){
    return 0;
}
function callback(){
    console.log("callback");
}
poll(checkStatus,callback);

that"s all I can think of, but I still use global variables to solve!

Mar.21,2021


function poll (checkStatus,callback,time) {
        if(checkStatus()){
            callback()
        }else{
            setTimeout(()=>{
                poll(checkStatus,callback,time*1.5)
            },time)
        }
    }
    function checkStatus(){
        return true;
    }
    function callback () {
        console.log()
    }
    poll(checkStatus,callback,1000)

is that all right?

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1eae10c-4f677.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1eae10c-4f677.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?