freeCodeCamp icon indicating copy to clipboard operation
freeCodeCamp copied to clipboard

My code seems to be generating the right output but it's not passing the tests

Open diegomm77 opened this issue 11 years ago • 2 comments

Challenge http://freecodecamp.com/challenges/bonfire-steamroller has an issue. Please describe how to reproduce it, and include links to screenshots if possible.

Code:

var arr1 = []; function steamroller(arr) { // I'm a steamroller, baby for (var i = 0; i < arr.length; i++) { if (Array.isArray(arr[i])) { steamroller(arr[i]); } else { arr1.push(arr[i]); } } return arr1; }

steamroller([1, [2], [3, [[4]]]]);

diegomm77 avatar Aug 28 '15 23:08 diegomm77

@diegomm77 right now there is a problem with your code. When you declare var arr1 = []; outside of your function it doesn't get reset each time a test is run. You can see this if you look at the results of your first failed test. Your current code returns [ 1, 2, 3, 4, 'a', 'b' ] instead of [ 'a', 'b' ]. Once you figure out how to solve this issue you will pass the challenge.

catapixel avatar Sep 01 '15 19:09 catapixel

@catapixel Thank you sir.

diegomm77 avatar Sep 01 '15 21:09 diegomm77