Skip to content

Steamroller solution working fine, but not passing the level #7655

Closed
shrihari-balasubramani opened this Issue · 1 comment

2 participants

@shrihari-balasubramani

Challenge Steamroller has an issue.
User Agent is: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:44.0) Gecko/20100101 Firefox/44.0.
Please describe how to reproduce this issue, and include links to screenshots if possible.

My code:

var gloabArr =[];
function getMyBabies(arr){
   var count =0;
  for(count=0;count<arr.length;count++){
      if(Array.isArray(arr[count])){
        getMyBabies(arr[count]);
      }
    else{
      gloabArr.push(arr[count]);
    }
  }
}
function steamroller(arr) {
  getMyBabies(arr);
  return gloabArr;

}
steamroller([1, {}, [3, [[4]]]]);
@ltegman
Free Code Camp member

Global variables are bad. Think about what your code does if you call this function more than once. Thanks and happy coding!

@ltegman ltegman closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.