Project: Plan Shared Long Weekends

In Exercise: Combine Countries and Holidays, you built a client that reads both APIs, checks every response body, follows pages, and retries only what might succeed. Amara, Jonas, Keiko, and Mateo still don’t have the answer they wanted at the start of the course, though: which long weekends they could spend together.

In this project, you’ll build the planner that answers them, from a brief instead of a walkthrough. You’ll get what the planner must do, the APIs and saved responses it can use, a starter module for the calendar math, and what each graded exercise checks. Choosing the steps is up to you.

Read the Brief

The friends live in four countries, so a weekend works for two of them only when both have the same days off at home. A long weekend here is a Saturday and a Sunday joined by at least one public holiday—three or more days off in a row. May 1, 2026, Labor Day, is a Friday, so Portugal, Germany, and Mexico each get May 1 to May 3.

Here’s the brief. The finished planner:

  1. Takes a year. node plan.mjs 2027 plans 2027, and node plan.mjs plans 2026. process.argv[2] holds the first word after the filename, or undefined when there isn’t one.
  2. Asks for every friend’s data at once. Each friend needs one request to Nager.Date for the year’s holidays and one to the World Bank for their country’s name and capital city. That’s eight requests, all started before the planner waits for any of them.
  3. Counts nationwide public holidays only. A holiday counts when its holidayTypes list includes "Public" and its nationalHoliday is true, so the friend has it off wherever they live in their country. Mexico’s Good Friday is listed under "Bank", "School", and "Authorities", not "Public", so it doesn’t count. Regional holidays don’t count either, because the planner works at country level. You’ll meet this simplification again below.
  4. Lists the shared long weekends. Two or more friends share a long weekend when theirs start and end on the same days. The planner lists each shared weekend in date order, with the friends who share it, each with their country’s name and capital city.
  5. Checks every response’s status and shape. When a country has no data, the planner identifies the friend and country code, and it still plans for everyone else.
  6. Gives up on a slow response. Each request has a deadline of five seconds in your own runs. The planner says which request ran out of time.
  7. Retries a 503 once. That’s at most two requests for the same URL. A 404 gets no second request.

When the planner is done, a run for 2026 answers the friends’ question. A reference planner printed this on November 27, 2026, against the live APIs. Your wording and layout can differ:

Language: Text
$ node plan.mjs 2026
Long weekends in 2026 that two or more of you share:
2026-05-01 to 2026-05-03
  Amara: Portugal, Lisbon
  Jonas: Germany, Berlin
  Mateo: Mexico, Mexico City
2026-12-25 to 2026-12-27
  Amara: Portugal, Lisbon
  Jonas: Germany, Berlin
  Mateo: Mexico, Mexico City

The first weekend is the one the friends already sent to the trip board. Keiko isn’t in either, because Japan’s long weekends in 2026 start and end on other days. Her Golden Week, for example, runs from May 2 to May 6, but Nager.Date’s data stops at May 5. The planner works with the dates the API reports, and observed or substitute holidays, such as Japan’s May 6, can be missing from them.

Point 5 matters as soon as someone mistypes a code. With Mateo’s XX back in the list, the same reference planner printed this, with his two problems first and the weekends Amara and Jonas still share:

Language: Text
Mateo: GET https://date.nager.at/api/v4/Holidays/XX/2026 answered 404
Mateo: No country data for XX: The provided parameter value is not valid
Long weekends in 2026 that two or more of you share:
2026-05-01 to 2026-05-03
  Amara: Portugal, Lisbon
  Jonas: Germany, Berlin
2026-12-25 to 2026-12-27
  Amara: Portugal, Lisbon
  Jonas: Germany, Berlin

Locked learning resources

Join us and get access to thousands of tutorials and a community of expert JavaScript developers.

Unlock This Lesson

Already a member? Sign-In

Locked learning resources

The full lesson is for members only. Join us and get access to thousands of tutorials and a community of expert JavaScript developers.

Unlock This Lesson

Already a member? Sign-In

Become a Member to join the conversation.