Skip to content

Commit

Permalink
Obfuscate variable and function names to aid true understanding -- su…
Browse files Browse the repository at this point in the history
…ggested by timoxley
  • Loading branch information
ultrasaurus committed Dec 28, 2012
1 parent 64317bd commit 5ee5cc4
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 5ee5cc4

Please sign in to comment.