Keiji Matsuzaki avatar Keiji Matsuzaki committed 5fd2262

add question_4/sample_1

Comments (0)

Files changed (2)

question_4/sample_1/index.html

+<html>
+  <head>
+    <meta charset="UTF-8"/>
+    <title>pollution sample 1</title>
+  </head>
+  <body>
+    <div> <h1>pollution sample 1</h1>
+    </div>
+    <div id="odds-elements">
+    </div>
+    <script type="text/javascript" src="pollution.js"></script>
+    <script type="text/javascript">
+      // <![CDATA[
+      view_odds_value();
+      // ]]>
+    </script>
+  </body>
+</html>

question_4/sample_1/pollution.js

+Array.prototype.extend = {
+  map: function(cb){
+    var _l = this.length
+      , _r = [];
+    for(var i = 0; i < _l; i++){
+      _r.push(cb(this[i]));
+    }; 
+    return _r;
+  }
+};
+
+var odds = [1, 3, 5, 7, 9, 11, 13, 15];
+var evens = odds.map(function(xs){
+  return xs + 1;
+}); 
+
+var get_odds_value_at_keys = (function(){
+  var _r = [];
+  for(var i in odds){
+    _r.push(odds[i]);
+  }
+  return _r;
+})();
+
+var view_odds_value = function(){
+  var odds_view = document.getElementById("odds-elements"); 
+  odds_view.innerHTML = (function(){
+    var _r = [];
+    for(var i in odds){
+      _r.push(odds[i]);
+    }
+    return '<span>' + _r.join(', ') + '</span>';
+  })();
+};
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.