Yngvarr

Generation

generate functionFri, 18 Nov 2022

максимальное значение в многомерном массиве

function max(a) { var max = -Infinity; for (var i = 0; i < a.length; i++) if (!Array.isArray(a[i])) { if (a[i] > max) max = a[i]; } else { var t = max(a[i]); if (t > max) max = t; } return max; } max([[1, 2], [3]])

Javascript
Generate More

Questions about programming?Chat with your personal AI assistant