Tell us what’s happening:
Describe your issue in detail here.
**Your code so far**
function largestOfFour(arr) {
let maxArray = [];
for(let i =0; i<arr.length; i++){
let max = Number.MIN_VALUE;
for(let j=0; j<4; j++){
if(max < arr[i][j]) max = arr[i][j];
}
maxArray.push(max);
max = Number.MIN_VALUE;
}
return maxArray;
}
largestOfFour([[17, 23, 25, 12], [25, 7, 34, 48], [4, -10, 18, 21], [-72, -3, -17, -10]]);
**Your browser information:**
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.164 Safari/537.36
Challenge: Return Largest Numbers in Arrays
Link to the challenge:
ilenia
2
check what this is - it’s a positive value so it is bigger than any negative value
Rather than using some special value, personally I find it more natural to use a number that I know is in the current sub-array.
can you what works in js if I want the largest negative value?
What have you tried to use as your search term in Google? I get a pretty good result when I use “largest negative value javascript” as my search term.
(Again, this approach is not needed, as you can just use one of the elements in the sub-array as your initial guess of the max value in the sub-array)
system
Closed
6
This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.