Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
jimschubert committed Jan 15, 2015
1 parent e70ff75 commit 7422240
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 0 deletions.
36 changes: 36 additions & 0 deletions 2015-01-14/Animal.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
class Animal{
constructor(legs) {
switch (legs) {
case 2:
this.locomotion = 'bipedal';
break;
case 4:
this.locomotion = 'quadrapedal';
default:
}
}
move() {
process.stdout.writeln("I'm a %j animal!", this.locomotion);
}
static getTypeName() {
return "Animal";
}
}

class Bird extends Animal {
constructor(){
super(2);
}
}

class Lion extends Animal {
constructor(){
super(4);
}
}

var bird = new Bird();
bird.move();

var lion = new Lion();
lion.move();
18 changes: 18 additions & 0 deletions 2015-01-14/fib.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
var fibonacci = { };
fibonacci[Symbol.iterator] = function*() {
var pre = 0, cur = 1;
for (;;) {
var temp = pre;
pre = cur;
cur += temp;
yield cur;
}
}

for (var n of fibonacci) {
// truncate the sequence at 1000
if (n > 1000) {
break;
}
process.stdout.write(n + '\n');
}

0 comments on commit 7422240

Please sign in to comment.