01 / 04
Does something used once need a name?
So far you have written it in two steps: make a function into a variable, then hand that variable over.
But naming a function you hand over only once is a bit of a waste. Thinking of the name is work, and reading it means going back and forth between the lines.
In fact you can write the function straight where the argument goes.
const doTask = (task) => { task();};doTask(() => { console.log("tidied up");});Result
tidied up