In my attempts to modify the compose function to output to the console using different arguments, I am struggling to find a solution. The initial call of the compose function results in an undefined argument arg
. Consequently, the reduce function utilizes the first element of the array (console.clear()) as the starting value, which is then passed as the argument for the subsequent function, getCurrentTime.
When compose is invoked with convertToCivilianTime, it takes the output from serializeClockTime and passes it as the parameter for the first returned function in compose.
This raises the question: how can compose be called initially with an undefined arg
without triggering an error?
const compose = (...fns) =>
(arg) =>
fns.reduce( (composed, f) => f(composed), arg)
...
// Additional JavaScript functions and code
...
startTicking()