Created
November 28, 2015 11:54
-
-
Save radumazilu/e2da3c5fa0e74dda0d39 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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