Skip to content

Advent-Of-Vue/2022-secret-santa-generator

Repository files navigation

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: 'kevin@homealone.com' },
  { name: 'John McClane', email: 'john@yippeekiyay.com' },
  ...
]

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: 'kevin@homealone.com' }, giver: { name: 'John McClane', email: 'john@yippeekiyay.com' } }, ... ]

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

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published