'How can we pass argument to function which itself is passed as argument in javascript

function fun (a, b)  {
        console.log(a + ' ' + b);
        return a == b;
 }

function test(condition) {

    for(let i = 0; i < 1; i++) {
        if(condition()){
            break;
        }
    }
}

How can we pass function fun as an argument inside function test with the argument a and b (a and b are variable). writing test(fun('a', 'b')); is resulting in an error.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source