Code Monkey home page Code Monkey logo

2022-secret-santa-generator's Introduction

Advent Of Vue 2022

If you didn't get here from an email, read this section! Skip it otherwise.

Advent Of Vue is a series of 24 Vue coding challenges that are sent out every day from December 1 to December 24 via a dedicated newsletter. If you'd like to receive more of these puzzles in the future, go ahead and sign up!

Problem description

The elves decided that in the spirit of leveling up the Christmas Spirit, they want to promote "Secret Santa".

The principle of Secret Santa is rather simple: Everyone gives a gift to exactly ONE other person. This means that everyone receives exactly ONE present, no matter how many people participate. The mechanism should be random.

To promote this, the elves want to provide a web application that automatically matches every participating person randomly.

The code is almost finished, but the developer elves got stuck on the most difficult part: Actually assigning random "secret santas" to everyone.

This is where you some in!

In the file src/helpers/match.js, there is a function matchPeople to be completed. The input is an array of names and emails:

[
  { name: 'Kevin McCallister', email: '[email protected]' },
  { name: 'John McClane', email: '[email protected]' },
  ...
]

The goal is it to return an array that assigns every name (receiver of gift) a secret santa (giver of gift). The array should have the following structure: [ { receiver: { name: 'Kevin McCallister', email: '[email protected]' }, giver: { name: 'John McClane', email: '[email protected]' } }, ... ]

There are two rules to be followed:

  1. For every person there has to be one (and only one) giver
  2. A person cannot be their own giver

Working example

https://majestic-douhua-02c095.netlify.app/

Author

Marc Backes:

Based on a Stackblitz project by tony19

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.