I am new to JavaScript Functional programming. In code below, compose can't work without setInterval outside it and clear as the first argument also does't give the compose initial value.
So my question is how can compose work without the setInterval?
const clear = () => console.clear()
const f1 = () => 2
const log = message => console.log(message)
const compose = (...fns) =>
arg =>
fns.reduce(
(composed, f) => f(composed),
arg
)
setInterval(
compose(clear, f1, log), 1000
)