我正在实施一个项目,我必须找到minimum
笼子里老鼠的年龄和年龄。
我正在使用的代码是:
var earTags = "";
var miceAge = "";
var genoTypes = "";
for (var curr_mice_cnt = 0, mice_len = data.mice_info.length; curr_mice_cnt < mice_len; curr_mice_cnt++ )
{
alert("Inside for loop");
var m_info = data.mice_info[curr_mice_cnt];
console.log("Mice Len="+data.mice_info.length);
earTags = earTags + m_info.ear_tag + ", " ;
miceAge = miceAge + m_info.age + ", ";
genoTypes = genoTypes + getGenotypeName(m_info.genotype_id) + ", ";
var lowest = Number.POSITIVE_INFINITY;
var highest = Number.NEGATIVE_INFINITY;
var tmp;
for (var i=miceAge.length-1; i>=0; i--) {
tmp = miceAge[i].Cost;
if (tmp < lowest) lowest = tmp;
if (tmp > highest) highest = tmp;
}
console.log(highest, lowest);
}
现在我试图将miceage
它显示为字符串,我想找到字符串的最小值和最大值,我得到的错误是Miceage=Infinity
。
谁能帮我实现这个,或者你可以建议任何其他代码来实现这个。