rmurphey/js-assessment-answers — pull request #19 by IGZJavierPerez (2013-11-29 08:09:41+00:00)
Title: Improved curryIt() solution

Now, when you call the function, it could take a variable number of arguments. Thus it is not necessary to pass the arguments one by one.

A valid test for the solution might be:

```js
it('you should be able to create a "partial" function for variable number of applied arguments', function() {
var partialMe = function(x, y, z) {
return x / y * z;
};

var a = Math.random(), b = Math.random(), c = Math.random();
expect(answers.partialUsingArguments(partialMe)(a, b, c)).to.eql(partialMe(a, b, c));
expect(answers.partialUsingArguments(partialMe, a)(b, c)).to.eql(partialMe(a, b, c));
expect(answers.partialUsingArguments(partialMe, a, b)(c)).to.eql(partialMe(a, b, c));
expect(answers.partialUsingArguments(partialMe, a, b, c)()).to.eql(partialMe(a, b, c));
});

it('you should be able to curry existing functions', function() {
var curryMe = function(x, y, z) {
return x / y * z;
};

var a = Math.random(), b = Math.random(), c = Math.random(), result;

result = answers.curryIt(curryMe);
expect(typeof result).to.eql('function');

result = answers.curryIt(curryMe)(a);
expect(typeof result).to.eql('function');

result = answers.curryIt(curryMe)(a)(b);
expect(typeof result).to.eql('function');

result = answers.curryIt(curryMe)(a)(b)(c);
expect(typeof result).to.eql('number');
expect(result).to.eql(curryMe(a, b, c));

result = answers.curryIt(curryMe, a)(b, c);
expect(typeof result).to.eql('number');
expect(result).to.eql(curryMe(a, b, c));

result = answers.curryIt(curryMe, a, b, c);
expect(typeof result).to.eql('number');
expect(result).to.eql(curryMe(a, b, c));

result = answers.curryIt(curryMe, a, b)(c);
expect(typeof result).to.eql('number');
expect(result).to.eql(curryMe(a, b, c));

result = answers.curryIt(curryMe)(a, b, c);
expect(typeof result).to.eql('number');
expect(result).to.eql(curryMe(a, b, c));

result = answers.curryIt(curryMe)()()(a, b, c);
expect(typeof result).to.eql('number');
expect(result).to.eql(curryMe(a, b, c));
});
```