我想找到Math.min的行值,但我不知道如何找到它,即使我已经谷歌了几天。
有人能告诉我如何解决这个问题吗?
function getDataPointsFromCSV(csv) {
var dataPoints = csvLines = [];
var price;
var lowestv = Infinity;
<!-- read csv file
csvLines = csv.split(/[\r?\n|\r|\n]+/);
<!-- read row 1-10
for (var i = 1; i <= 10; i++)
if (csvLines[i].length > 0) {
<!-- read csv file
points = csvLines[i].split(",");
<!-- read the data from points[4]=(column5)
price = points[4]
<!-- find the row number which store lowest value in a column
lowestv = Math.min(price, lowestv)
<!-- fault example; the value that I want to find is lowestv.length
for (var i = lowestv.length; i <= lowestv.length+10; i++)
}
return dataPoints;
}
1条答案
按热度按时间pvcm50d11#
不要使用
Math.min()
。只需测试price
是否低于lowestv
。如果是,将价格保存在lowestv
中,并将该行保存在另一个变量中。