Skip to content

Commit affed2d

Browse files
committed
Add code piece from the book JavaScript The Good Parts
1 parent 20373e2 commit affed2d

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

JavaScript_The_Good_Parts.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// following JavaScript will run in a JS console, e.g. Firebug
2+
3+
var hanoi = function hanoi(disc, src, aux, dst) {
4+
if (disc > 0) {
5+
hanoi(disc - 1, src, dst, aux);
6+
console.log('Move disc ' + disc + ' from '
7+
+ src + ' to ' + dst);
8+
hanoi(disc - 1, aux, src, dst);
9+
}
10+
};
11+
12+
hanoi(3, 'Src', 'Aux', 'Dst');
13+

0 commit comments

Comments
 (0)