본문 바로가기

Algorithms

freeCodeCamp - 5. Return Largest Numbers in Arrays [Basic Algorithm Scripting]

Return Largest Numbers in Arrays

 

https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/basic-algorithm-scripting/return-largest-numbers-in-arrays

 

www.freecodecamp.org

 

 

function largestOfFour(arr) {
  let myArr = []
  for (let a of arr){
    console.log(a)
    myArr.push(Math.max.apply(null, a))
  } 
  return myArr;
}

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