Importing More Checks explainer

The aim of this puzzle: Use one of the imported “checking” functions as a callback

Walkthrough of the solution: The 1st line of code imports several functions. Importing is a way to include code that’s written somewhere else, in a different file. There are 4 “checking” functions that take a string and print out a message based on if the string includes a certain word. The checkPassport function looks for the word 'Passport'. The checkTicket function looks for the word 'Ticket'. And checkVehicle and checkHotel do a similar check.

In this puzzle, you need to change the callback function again. The callback is chosen where the updateAllAndCheck() is called. The 4th argument is the name of a function without parentheses. The checkPassport should be replaced with either checkTicket, checkVehicle, or checkHotel.

Sample code solution:
(Tap below to reveal)

import { updateAllNames, checkPassport, checkTicket, checkVehicle, checkHotel } from '';

function updateAllAndCheck(string, oldPart, newPart, extraCheck) {
  return updateAllNames(string, oldPart, newPart);

travelDocument = updateAllAndCheck(travelDocument, 'grasshoper', 'grasshopper', checkVehicle);

JavaScript Concepts: Callback Functions, Calling Functions, Code Block (function), console.log(), import

CheckFunction & grasshopper. Travel, what are those? File name or what? In the same folder or from other folder?


The things inside the curly brackets are functions or data that are exported from another file. The location of this file is specified using a string. If the file is in another folder, you’ll need to navigate to that folder inside your string, for example, '/anotherFolder/'. There’s more info here.


1 Like