main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
// small example by Morten from codesoul.com

function oldStyleWayToYell(count) {
    var res = 'he';
    for (var i = 0; i < count; i++){
        res += "y";
    }  
    return res;
}

var ninja = { 
  yell: function(n){ 
    return n > 0 ? ninja.yell(n-1) + "a" : "hiy"; 
  } 
};

console.log('old style way to yell: ' + oldStyleWayToYell(5));
console.log('functional ninja yell: ' + ninja.yell(42)); 
Native Browser JavaScript