Skip to content

Commit

Permalink
Merge pull request hackreactor#17 from blazingcloud/master
Browse files Browse the repository at this point in the history
Fix for Issue #: Obfuscate variable and function names to aid true understanding
  • Loading branch information
David Laing committed Dec 28, 2012
2 parents 64317bd + 5ee5cc4 commit dc6daac
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions koans/AboutFunctions.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,20 @@ describe("About Functions", function() {
});

it("should use lexical scoping to synthesise functions", function () {

function makeIncreaseByFunction(increaseByAmount) {
var increaseByFunction = function increaseBy(numberToIncrease) {
return numberToIncrease + increaseByAmount;

function makeMysteryFunction(makerValue)
{
var newFunction = function doMysteriousThing(param)
{
return makerValue + param;
};
return increaseByFunction;
return newFunction;
}
var increaseBy3 = makeIncreaseByFunction(3);
var increaseBy5 = makeIncreaseByFunction(5);
expect(increaseBy3(10) + increaseBy5(10)).toBe(FILL_ME_IN);

var mysteryFunction3 = makeMysteryFunction(3);
var mysteryFunction5 = makeMysteryFunction(5);

expect(mysteryFunction3(10) + mysteryFunction5(5)).toBe(FILL_ME_IN);
});

it("should allow extra function arguments", function () {
Expand Down

0 comments on commit dc6daac

Please sign in to comment.