Return Largest Number In array arr[i][0]

Tell us what’s happening:
Describe your issue in detail here.
I am wondering what the point of
let LongNum =arr[i][0];
what does the [0] do? please help me thank you.

   **Your code so far**
function largestOfFour(arr) {
 let result = []
 for (let i=0; i<arr.length; i++){
   let longNum = arr[i][0]
   for(let j = 1; j<arr[i].length; j++){
     if(arr[i][j] > longNum){
  result[i] = longNum;
return result;

console.log(largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1], [10,5,10,15]]));
   **Your browser information:**

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.5005.63 Safari/537.36

Challenge: Return Largest Numbers in Arrays

Link to the challenge:

All it does is provide a starting place for comparisons of each sub array. It assigns the first element of each sub array to be the longest (it may or may not be but it does not matter). Then, the inner for loop compares each number of the sub array to logNum which of course can change while iterating. There is a bit of redundancy because in the first iteration of the inner for loop, the first element of the sub array gets compared to itself, but that is fine.

Thank you. You explained it perfectly.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.