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

Friday, May 12, 2017

FreeCodeCamp Chunky Monkey Sample Solution


function chunkArrayInGroups(arr, size) {
  // Break it up.
  var temp = [];
  var divisions = arr.length / size;
  while(arr.length>0){
    var temp2 = [];
    for(var i=0; i<size; i++){
      if(arr.length<=0){
        break;
      }
      temp2.push(arr.shift());
    }
    temp.push(temp2);
  }
  return temp;
}

chunkArrayInGroups(["a", "b", "c", "d"], 2);

No comments:

Post a Comment


This is an example of scrolling text using Javascript.

Popular Posts