I have the following situation where I have a function f which takes an argument input.
f
input
I want to be able to have f such that
Try this
function f(input) { let str = 'f' var o = function(suffix){ if(suffix) return str + suffix; str += "o"; return o; } return o(input); } console.log(f('l')) console.log(f()('l')) console.log(f()()('l')) console.log(f()()()('l'))