Tell us what’s happening:
I wrote some code for the Steamroller exercise in the Intermediate Algorithm Scripting unit. I have pasted in all of the test cases to log out the results and they all return the correct values, but the test results just says that they should return the correct values!
Any idea why this is not being accepted? Thanks!
Your code so far
function steamrollArray(arr) {
for(let x in arr){
if(Array.isArray(arr[x])){
steamrollArray(arr[x]);
}else{
newArr.push(arr[x]);
}
}
return newArr;
}
var newArr = [];
console.log(steamrollArray([[["a"]], [["b"]]]));
var newArr = [];
console.log(steamrollArray([1, [2], [3, [[4]]]]));
var newArr = [];
console.log(steamrollArray([1, [], [3, [[4]]]]));
var newArr = [];
console.log(steamrollArray([1, {}, [3, [[4]]]]));
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:75.0) Gecko/20100101 Firefox/75.0
.
Challenge: Steamroller
Link to the challenge: