ðŸŽ‰ Exercism Research is now launched. Help Exercism, help science and have some fun at research.exercism.io ðŸŽ‰

# lujanfernaud's solution

## to Two Fer (Legacy) in the JavaScript Track

Published at Jul 13 2018 · 0 comments
Instructions
Test suite
Solution

#### Note:

This solution was written on an old version of Exercism. The tests below might not correspond to the solution code, and the exercise may have changed since this code was written.

# Two Fer

`Two-fer` or `2-fer` is short for two for one. One for you and one for me.

``````"One for X, one for me."
``````

When X is a name or "you".

If the given name is "Alice", the result should be "One for Alice, one for me." If no name is given, the result should be "One for you, one for me."

## Setup

Go through the setup instructions for JavaScript to install the necessary dependencies:

http://exercism.io/languages/javascript/installation

## Running the test suite

The provided test suite uses Jasmine. You can install it by opening a terminal window and running the following command:

``````npm install -g jasmine
``````

Run the test suite from the exercise directory with:

``````jasmine two-fer.spec.js
``````

In many test suites all but the first test have been marked "pending". Once you get a test passing, activate the next one by changing `xit` to `it`.

## Source

This is an exercise to introduce users to basic programming constructs, just after Hello World. https://en.wikipedia.org/wiki/Two-fer

## Submitting Incomplete Solutions

It's possible to submit an incomplete solution so you can see how others have completed the exercise.

### two-fer.spec.js

``````var TwoFer = require('./two-fer');

describe('Two Fer', function () {
var twoFer = new TwoFer();

it('gives one to you if no parameter given', function () {
expect(twoFer.twoFer()).toEqual('One for you, one for me.');
});

xit('gives one to Alice if \'Alice\' is given', function () {
expect(twoFer.twoFer('Alice')).toEqual('One for Alice, one for me.');
});

xit('gives one to Bob if \'Bob\' is given', function () {
expect(twoFer.twoFer('Bob')).toEqual('One for Bob, one for me.');
});
});``````
``````var TwoFer = function () {};

TwoFer.prototype.twoFer = function (who = "you") {
return `One for \${who}, one for me.`;
};

module.exports = TwoFer;``````