JSFiddle - React, Tailwind, and code Playground

by Jessie Lau

JavaScript

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

    function makeMysteryFunction(makerValue)
    {
      var newFunction = function doMysteriousThing(param)
      {
        return makerValue + param;
      };
      return newFunction;
    }

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

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