JavaScript --Example #10 from John Resig`s Learning Advanced JavaScript
<p>I<code>m reading John Resig</code>s "Learning Advanced JavaScript" <a href="http://ejohn.org/apps/learn/#10" rel="nofollow">http://ejohn.org/apps/learn/#10</a> and came across this function below that I don`t understand. </p>

<p>The function yell is called with an argument of 4. When this is done, the argument 4 is run through the terniary operator. If it is greater than zero, which it is, then we come to <code>yell(n-1) + a</code>
My questions relate to this.</p>

<p>a) does <code>yell(n-1) + a</code> call the function again (i.e. restart it) with an argument of 3. </p>

<p>b) If you do <code>(n-1) + a,</code> you get a result of 3a. Does JavaScript convert 3a to "aaa". I ask this because in the assert line it says <code>yell(4) == "hiyaaaa"</code></p>

<p>c) after converting it, does it somehow add it to "hiy"? I don`t understand how. </p>

<p>d) if JavaScript does convert 3a to a string of "aaa"s, and somehow manages to add it to "hiy", I don`t understand why yell(4)=hiyaaaa.  Yell(n-1) + a = hiyaaa (3as), not hiyaaaa(4"a"s). </p>

<p>As you can see I am totally confused. </p>

<pre><code>function yell(n){
  return n &gt; 0 ? yell(n-1) + "a" : "hiy";
}
assert( yell(4) == "hiyaaaa", "Calling the function by itself comes naturally." );
</code></pre>
