Website that runs a Secret Friend game. Made with HTML, CSS and JavaScript for studies and portfolio purposes only. This assignment is part of the ONE: Oracle Next Education program.
- Can add or remove as many names as you want;
- Randomly picks a name to be your Secret Friend;
- Buttons are disabled as long as they can't do their job;
- Can hide the name of the last name drawn in order to not spoil the secret when playing with more than one person;
- Restart button (clears every entry and data to start a fresh game);
- Buttons with nice pressing animations;
- An error message is prompted if the input is empty;
- A warning is displayed when all the inputed names have been drawn (can't draw repeated names!);
- Fully responsive!
-
Stores user inputs (friends' names) in two arrays:
- Friends array is displayed and updated as it grows or shrinks;
- Secret array just stores the names.
-
When the
Draw a secret friendbutton is pressed the system checks if there are any elements inside the Secret array:-
If there are:
- An element from the Secret array is picked randomly;
- Said element is then stored in a variable and this new variable is displayed as the Secret Friend result;
- Said element is then removed from the Secret array.
-
If Secret array is empty:
- Displays a "There are no more names to draw!" message and disables the draw button.
-
- Download the
app.js,styles.css,index.htmlfiles and theassetsfolder; - Create a folder and paste all the files in it;
- Run
index.htmlon a live server or in your preferred way to do so.
- Type the name of your friends and click
Addor press Enter; - Names will be displayed as buttons, click on a name to remove it from the list if you wish;
- Click on
Draw a secret friendto randomly pick a name; - Click on
Hide secret nameto hide the current result; - Click on
Restart gameto clear everything and start a fresh game. - When there are no more names left to be drawn, you can either add more or reset the game.
