1. Keiji Matsuzaki
  2. my_answer

Commits

Keiji Matsuzaki  committed 5fd2262

add question_4/sample_1

  • Participants
  • Parent commits 22d210b
  • Branches default

Comments (0)

Files changed (2)

File question_4/sample_1/index.html

View file
+<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>

File question_4/sample_1/pollution.js

View file
+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>';
+  })();
+};