Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
diegomm77 opened this issue Aug 28, 2015 · 2 comments

Comments

@diegomm77
Copy link

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]]]]);

@catapixel
Copy link

@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.

@diegomm77
Copy link
Author

@catapixel Thank you sir.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants