In this exercise your objective will be to write a pairs()
function.
pairs()
has the following features:
-
It accepts an array of names:
pairs(['Asis', 'Hamsa', 'Fawas', 'Mishmish'])
-
It returns a randomized pairing of the people in the list:
[['Mishmish', 'Asis'], ['Fawas', 'Hamsa']]
-
It can handle an odd number of names:
pairs(['Asis', 'Hamsa', 'Fawas', 'Mishmish', 'Hussein])
returns[['Mishmish', 'Fawas'], ['Asis', 'Hussein'], ['Hamsa']]
-
It returns an empty array if it gets passed nothing:
pairs()
returns[]
- Install
node
:$ brew install node
- Install
yarn
:$ brew install yarn --without-node
Fork this repository and clone your fork (make sure you clone it into your development
directory):
$ git clone https://github.com/<your_username>/JSEpisode1.git
Inside you'll find two .js
files:
pairs.js
- this is the file you'll be editingpairs.spec.js
- this is a testing file. It checks that yourpairs()
function has the features discussed above.
DO NOT EDIT THIS FILE
Install all the requirements:
- Navigate to the project root (you'll find a file called
package.json
there). - Install the requirments using
yarn install
.
Run the tests:
$ yarn test
This command will run the testing file and test your pairs()
function to make sure it has all the required features.
You'll know when you're done when your code passes all the tests.