JavaScript Math (parameter passing, arrays, and the "apply" method)
<p>1) Why does the <code>function smallest</code> fail? I think it conforms to the example in the Mozilla documentation <a href="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Math/min" rel="nofollow">https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Math/min</a>, which says</p>

<pre><code> function getMin(x,y) {  //from Mozilla documentation
   return Math.min(x,y)
}



function smallest(array){ //my own experimentation with Resig`s example
  return Math.min(array);
}
function largest(array){      //from John Resig`s learning advanced JavaScript #41
  return Math.max.apply( Math, array );
}
assert(smallest([0, 1, 2, 3]) == 0, "Locate the smallest value.");
assert(largest([0, 1, 2, 3]) == 3, "Locate the largest value.");
</code></pre>
