L
L
leyarthemes2019-07-24 08:16:39
JavaScript
leyarthemes, 2019-07-24 08:16:39

How to find out the length of the longest row and column of a 2d array?

Hello, please tell me how to pass the length (length) of the largest subarray from the val array to the testFunc() function, and, if possible, the length of the largest column (for example, a column with index 1 - 7, "", 9). The number of subarrays is unknown.

var val = [
["",7,17,27,17],
["","",18,28,18,18,18,18,18],
["",9,19,29,19]
]

var newVal = val.map(function(e) {
  return testFunc();
});

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Ronald McDonald, 2019-07-24
@leyarthemes

The task is simple. For each line, calculate the number of elements, drive it into an array and look for the maximum in this array. The index of the largest value will be equal to the index of the longest string. Clear and simple.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question