イム、しかし、誰もがこの1で私を助けることができる場合、私は思っていた:ジョンResig氏高度なJavascriptの質問は、私の頭の上に少しで
から取ら:http://ejohn.org/apps/learn/#43
function highest(){
return arguments.slice(1).sort(function(a,b){
return b - a;
});
}
assert(highest(1, 1, 2, 3)[0] == 3, "Get the highest value.");
assert(highest(3, 1, 2, 3, 4, 5)[1] == 4, "Verify the results.");
私はそれを考えました
Array.prototype.highest = function(){
return arguments.slice(1).sort(function(a,b){
return b - a;
});
}
assert(highest(1, 1, 2, 3)[0] == 1, "Get the highest value.");
assert(highest(3, 1, 2, 3, 4, 5)[1] == 1, "Verify the results.");
これは私に未定義のエラーを与えています。
、間違っては、なぜあなたは 'highest'への最初のパラメータを無視しているMath.max –