Named functions hoist. Functions stored in variables don’t.
Move the function up or use a named function.