Just a Minute explainer


#1

The aim of this puzzle: Use an imported function as a callback.

Walkthrough of the solution: The solution to this puzzle is similar to the previous ones. The only difference is that the callbacks aren’t declared in code, but they aren’t entirely in hidden code either. The 1st line is an import statement. An import can access data or functions from another location. In this case, clockActions, which would be the name of another file.

To snooze the reminder, you call the clockAction() function, and use a number of minutes and the snoozeReminder callback.

Sample code solution:
(Tap below to reveal)

import { setTimer, snoozeTimer, setReminder, snoozeReminder } from 'clockActions';

function clockAction(time, type) {
  console.log('Clock opened...');
  type(time);
}

clockAction(10, snoozeTimer);
clockAction(5, snoozeReminder);

JavaScript Concepts: console.log(), Callback Functions, import, Function Declarations