Gabriele Ferro Home

Dev Advent Calendar – Day #03

Yesterday's puzzle was about creating the menu for the Elf Coffee Shop.

But now, the pretentious elves want an app where they can order their drink and it would be delivered to their place. And they want it TODAY!

We already created the menu so the only thing missing is a REST API to get the drinks.

For the moment... our job is to populate the API with the correct data, so it can be consumed by the app.

In this coding challenge we have to return an array of every item on the menu, with some additional data:

The "slugified" version of the name will be probably useful later, when we will build the page for each single item.
The "slug" part of an URL address is the "easy-to-read" information and it is very important for SEO.

In this case we will need to write two function:

  1. slugify
  2. prepareForAPI

Fortunately, a hint is provided in the case of accents because I couldn't remember how to filter them. Searching the internet I also found a different way of filtering the various characters using a dictionary. But I did not use this approach.

Here is my solution

The slugify function uses Regular Expressions to transform the string into slug format
The prepareForAPI function uses the technique of composing objects


  1. Click the participation link
  2. Clone your repository
  3. Solve the puzzle
  4. Test your solution
  5. Add your Twitter handle
  6. Git push your changes

June 2024


Gabriele Ferro Home
Copyright © Ferro Gabriele. All rights reserved.