Giter Club home page Giter Club logo

puzzle-3's Introduction

ℹ️ For detailed information about the contest, check out devadvent/readme

Dev Advent Calendar 🎅 Puzzle 3 - Elf Coffee Shop API 🧝🥤

Yesterday's puzzle was about creating the menu for the Elf Coffee Shop. The owner was very satisfied with the result.

Due to the high demand, the savy entrepreneur hired someone to make an app where elves can order their drink, and it would be delivered home, or to their workplace.

The only thing missing is a REST API to get the drinks. It is your job to populate the API with the correct data, so it can be consumed by the app.

🧩 The puzzle

The REST API is already set up, but you need to prepare the menu data in a specific way.

This puzzle might be a little bit harder than the previous. But I am sure you can do it 💪

1️⃣ First step

Complete the function prepareForApi in the file utils/menu.js: Return an array of every item on the menu, with some additional data:

  • name: Complete name, consisting of flavor + drink. Drinks with no extra flavors will just ommit the flavor field. (e.g. Hot Chocolate, Gingerbread Latte, Peppermint Cappuccino, etc.)

  • slug: A slugified version of the name (check /utils/helpers.js) (e.g. hot-chocolate, gingerbread-latte, peppermint-cappuccino, etc.) Example:

     ```javascript
     [
         {
             drink: 'Latte',
             flavor: 'Gingerbread',
             price: 4.5,
             name: 'Gingerbread Latte',
             slug: 'gingerbread-latte',
         },
         ...
     ]
     ```
    

2️⃣ Second step

For the first step to work, you also need to complete the slugify function in the utils/helpers.js.

Return a "slugified" version of a given text (String). This means:

  • Everything in lowercase
  • Replace all letters with accents, umlauts, etc. to a normalized letter (e.g. Déjà Vu ➡️ deja-vu, Jürgen ➡️ jurgen, etc.) (💡 hint: https://stackoverflow.com/questions/990904/remove-accents-diacritics-in-a-string-in-javascript)
  • Replace all other non-alphanumeric characters (incl. spaces) with a hyphen (-)
  • Remove leading and trailing hyphens (-test-123 ➡️ test-123, hello-world- ➡️ hello-world)
  • Multiple consecutive hyphens should replaced with a single hyphen (some-----spaces ➡️ some-spaces)

🚢 Ship your solution

Check out the contributing guide for details about how to participate.

In short:

  • ✨ Create your repository by acceping the assignment using the participation link
  • 🧩 Solve the puzzle
  • 🐦 Add your Twitter handle to twitter.js
  • 🤖 Test your solution
  • 🚀 Upload your changes to the main branch

🔗 Participation link

In order to participate, you need to enter the following link and accept the assignment: https://classroom.github.com/a/MLFACYY8

💻 Use this project

⏳ Install the dependencies

Install the dependencies with

yarn install

or

npm install

⚙️ Run the code

Run the code with

yarn dev

or

npm run dev

💡 You can consume the API by directing your browser to [http://localhost:3000/api/menu]

🤖 Test your solution

This puzzle is equipped with automated tests (in the ./tests folder). In order for your solution to qualify for winning the daily prize, all tests need to pass.

To run these tests, execute one of the following commands in your console:

yarn test

or

npm test

puzzle-3's People

Contributors

themarcba avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.