Quotes help make search much faster. Example: "Practice Makes Perfect"

Friday, May 12, 2017

FreeCodeCamp Return Largest Numbers In Arrays Sample Solution


function largestOfFour(arr) {
  // You can do this!
  var largestArr = [];
  for(var i=0; i<arr.length; i++){
    var temp = -1000000;
    for(var j=0; j<arr[i].length; j++){
      if(temp < arr[i][j]){
        temp = arr[i][j];
      }
    }
    largestArr.push(temp);
  }
  return largestArr;
}

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

No comments:

Post a Comment


This is an example of scrolling text using Javascript.

Popular Posts