gpt4 book ai didi

javascript - JS或jQuery获取数组中的最大值

转载 作者:行者123 更新时间:2023-11-29 17:27:00 25 4
gpt4 key购买 nike

我正在使用流程图库绘制图表。下面是图形的 xy 坐标数组。

var plottingPoints  = [[0, 3], [4, 8], [8, 5], [9, 23], [10, 2]];

我只需要选择 y 坐标的最大值(即 23)。请需要专业知识的支持。

最佳答案

var plottingPoints  = [[0, 3], [4, 8], [8, 5], [9, 23], [10, 2]];
var length = plottingPoints.length;
var maxY = -Infinity;
for(var i = 0; i < length; i++)
maxY = Math.max(plottingPoints[i][1], maxY);

关于javascript - JS或jQuery获取数组中的最大值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7889742/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com