Anonymous avatar Anonymous committed 3378646

Add exercise 1.

Comments (0)

Files changed (3)

core-javascript/exercise-1.rst

+Exercise one
+============
+
+Here's some JavaScript code I found somewhere.  I've changed the names
+of everything to hide the origin of the code.  But it's not something
+I've made up.
+
+The exercise is
+
+#.  Understand and describe what it does.
+
+#.  Provide clearer code that does the same thing.
+
+#.  Suggest a better way of going about things.
+
+.. literalinclude:: /js/exercise-1.js
+   :language: javascript
+
+
+Hints
+=====
+
+#.  The code creates and calls an anonymous function, a bit like this.
+
+    .. code-block:: javascript
+
+       js> a = function(x){return x + 1}(2)
+       3
+
+#.  What happens if AAA is an object?
+
+#.  What happens if AAA is undefined?
+
+#.  For now, ignore the assignment to BBB.fff.  What value does AAA
+    get?  (The answer depends the initial value of AAA.)

core-javascript/index.rst

    object-tree
    global
 
+   exercise-1
+
+
 Indices and tables
 ==================
 

core-javascript/js/exercise-1.js

+var AAA = (function (BBB) 
+{
+    BBB.fff = function(ccc) 
+    {
+        return {
+            ggg: function(ddd) 
+            {
+                return BBB.hhh(ddd, ccc.iii() );
+            }
+        };
+    };
+    return BBB;
+
+}(AAA || {}));
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.