How to approach bonfires

I was working through the algorithm Return Largest Numbers in Arrays and I got the solution, but I was wondering if the way I attacked the problem is correct. Is part of solving these challenges figuring a way to get the solution from researching online? Obviously not copying and pasting, but to look up methods and functions on MDN appropriate?

For instance, this was my code to solve the problem:

function largestOfFour(arr) {
// You can do this!
for(var i=0; i<arr.length; i++) {
arr[i]= Math.max.apply(null, arr[i]);
return arr;

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);

I assumed there was something related to Math.max() , so I googled it and read on how to use it in MDN. Is what I did a valid way to solve this problem? Or does FCC want us to reinvent the wheel and figure out how to solve it by what I would assume go through each array and compare the values within the arrays?

Thanks in advance!

if your intention is to make your code as short as possible then you can use ES6 features. Something like this:

function largestOfFour(arr) {
  return => Math.max(...x));


1 Like

You’ve absolutely got the right idea. Looking up stuff in the MDN is excellent.

Don’t be too concerned if you need to look it up in more low-brow places either, like WS3Schools or Youtube :wink:

The goal of the bonfires is to teach you how to solve problems by breaking them down into small, reasonable processes and learning how to do those in JS. Don’t be too concerned about being as short as possible yet, or using ES6 features as Laney suggests - just focus on taking a methodical approach to problem solving and figuring out what questions to ask when you get stuck!

1 Like

Thanks for the feedback!!