loading...

re: Explain This Like I'm Five VIEW POST

TOP OF THREAD FULL DISCUSSION
re: What did you write as your solution? I think I can guess what the issue is and your confusion. I can't see the prompt, but the way it's written it...
 

And for good measure, what I had thought they wanted and how I would've written it:

function getMaxOfAllArrays(groupOfArrays) {
        var largestNumberArray = [];
        var largestNumber = 0; // picking 0 to start

        // loop through our arrays
        for (var whichArray = 0; whichArray < groupOfArrays.length; whichArray++) {
            var currentArray = groupOfArrays[whichArray];

            // index change -- since we are no longer comparing within the array
            // we need to loop through the whole thing.
            for (var whichNumber = 0; whichNumber < currentArray.length; whichNumber++) {

                var currentNumber = currentArray[whichNumber];

                if (currentNumber > largestNumber) {
                    largestNumber = currentNumber;
                    // we can't stop here--what about the other arrays?
                }
            }
        }

        // return the max
        return largestNumber;
    }
Code of Conduct Report abuse