Skip to content

Instantly share code, notes, and snippets.

@radumazilu
Created November 28, 2015 11:54
Show Gist options
  • Save radumazilu/e2da3c5fa0e74dda0d39 to your computer and use it in GitHub Desktop.
Save radumazilu/e2da3c5fa0e74dda0d39 to your computer and use it in GitHub Desktop.
// Bonfire: Steamroller
// Author: @radumazilu
// Challenge: http://www.freecodecamp.com/challenges/bonfire-steamroller
// Learn to Code at Free Code Camp (www.freecodecamp.com)
function steamroller(arr) {
// I'm a steamroller, baby
var newArr = [];
var check = function(x){
if(Array.isArray(x) !== true){
newArr.push(x);
}else{
for(var i = 0; i < x.length; i++){
check(x[i]);
}
}
};
for(var i = 0; i < arr.length; i++){
check(arr[i]);
}
return newArr;
}
steamroller([[["a"]], [["b"]]]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment