Tell us what’s happening:
Output is correct when test locally but code is not passing FCC
**Your code so far**
let c=new Array();
function largestOfFour(arr) {
arr.map(a=>{
let b=Math.max(...a);
c.push(b);
});
return c;
}
largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
**Your browser information:**
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.71 Safari/537.36
Challenge: Return Largest Numbers in Arrays
Link to the challenge:
const one = largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
const two = largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
console.log(two);
What gets logged?
Hi Dan,
Thank you for your response. I am getting this output
[
5, 27, 39,
1001, 5, 27,
39, 1001
]
ilenia
October 8, 2021, 11:12am
#4
and is it the right output?
do you understand why you get it?
Hi Ilenia,
Ohh, Its outputting double values which is wrong.
Hi,
Thank you everyone for your help. You helped me to question further about my code. I resolved it. Below is the updated code.
function largestOfFour(arr) {
let c=new Array();// I added the array now in function
arr.map(a=>{
let b=Math.max(...a);
c.push(b);
});
return c;
}
largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
2 Likes
Congratulation on working through the problem! Good job debugging.
1 Like
system
closed
April 9, 2022, 6:51am
#8
This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.