AlgoDaily Solution

1var assert = require('assert');
2
3/*
4 *  Closures
5 */
6var minus = (function () {
7  var counter = 999;
8  return function () {
9    counter -= 1;
10    return counter;
11  };
12})();
13
14minus();
15minus();
16minus();
17
18/*
19 *  Dependency Injection With Closures
20 */
21function createFactories(logger) {
22  return {
23    emailFactory: function (greeting) {
24      return function (greet) {
25        logger(greeting + greet);
26      };
27    },
28    smsFactory: function (text) {
29      return function (text) {
30        logger(text);
31      };
32    },
33  };
34}

Community Solutions

Community solutions are only available for premium users.

Access all course materials today

The rest of this tutorial's contents are only available for premium members. Please explore your options at the link below.

Returning members can login to stop seeing this.

JAVASCRIPT
OUTPUT
Results will appear here.